Skip to content

Optional xet-backed HF downloads (LLAMA_XET) - #1

Open
assafvayner wants to merge 1 commit into
masterfrom
xet-download
Open

Optional xet-backed HF downloads (LLAMA_XET)#1
assafvayner wants to merge 1 commit into
masterfrom
xet-download

Conversation

@assafvayner

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in path that downloads xet-backed HuggingFace files through the xet-core C API (xet_capi) instead of a direct HTTP GET. Gated behind the LLAMA_XET CMake option (OFF by default), so the normal build and behavior are unchanged.

This is an experiment to evaluate presenting a native xet client integration to the llama.cpp maintainers; it is not intended for upstream as-is.

Changes

  • Build (CMakeLists.txt, common/CMakeLists.txt): new LLAMA_XET option. When ON, add_subdirectory the xet_capi crate from XET_CORE_DIR, define LLAMA_USE_XET, and link xet_capi (with platform native libs handled by the crate's CMake glue).
  • Discovery (common/hf-cache.{h,cpp}): parse the tree API's top-level size and xetHash; for xet-backed files, record the xet hash and build the read-token URL (<endpoint>/api/models/<repo>/xet-read-token/<commit>).
  • Download (common/download.{h,cpp}): carry xet hash / token URL / sha256 / size on the download task; add a per-file xet download (guarded by LLAMA_USE_XET) via the xet_session.hpp C++ RAII wrapper. On any error it warns and falls back to the existing HTTP download. The CAS endpoint comes from the token response's casUrl.

Dependencies

The xet C API crate and its CMake glue live on the xet-core assaf/c-api branch: huggingface/xet-core#881. Build with -DLLAMA_XET=ON -DXET_CORE_DIR=/path/to/xet-core.

Verification

End-to-end against a xet-backed repo (bartowski/SmolLM2-135M-Instruct-GGUF): the model is reconstructed via the xet protocol and written into the standard HF cache layout (blobs/snapshots/refs); with LLAMA_XET=OFF the build is byte-for-byte the existing HTTP path.

Adds an opt-in path that reconstructs xet-backed HuggingFace files through
the xet-core C API (xet_capi) instead of a direct HTTP GET. Gated behind the
LLAMA_XET CMake option (OFF by default), so the normal build is unchanged.

- CMakeLists.txt / common/CMakeLists.txt: add LLAMA_XET option; when ON,
  add_subdirectory the xet_capi crate from XET_CORE_DIR, define LLAMA_USE_XET,
  and link xet_capi.
- common/hf-cache.{h,cpp}: parse the tree API's top-level size and xetHash;
  when a file is xet-backed, record its xet hash and build the read-token URL
  (<endpoint>/api/models/<repo>/xet-read-token/<commit>).
- common/download.{h,cpp}: carry xet hash / token URL / sha256 / size on the
  download task; add a per-file xet download (guarded by LLAMA_USE_XET) using
  the xet_session.hpp C++ wrapper. On any error it warns and falls back to the
  existing HTTP download. The CAS endpoint comes from the token response.

The xet C API and CMake glue live on the xet-core assaf/c-api branch
(huggingface/xet-core#881).

Assisted-by: Claude Code (Opus 4.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant