Skip to content

feat: add chunk_byte_sizes to XorbReconstructionTerm, with a client opt-in - #691

Closed
XciD wants to merge 2 commits into
mainfrom
feat/chunk-byte-sizes-in-reconstruction-term
Closed

XciD wants to merge 2 commits into
mainfrom
feat/chunk-byte-sizes-in-reconstruction-term

Conversation

@XciD

@XciD XciD commented Mar 10, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add an optional chunk_byte_sizes: Vec<u32> to XorbReconstructionTerm: the uncompressed size of each chunk of the term's range, in chunk order. It is skipped when empty, so the wire format does not change for clients that do not ask.
  • Add client.reconstruction_chunk_byte_sizes (HF_XET_CLIENT_RECONSTRUCTION_CHUNK_BYTE_SIZES, off by default). When set, RemoteClient adds ?chunk_byte_sizes=true to its V1 and V2 reconstruction requests.
  • The CAS server (huggingface-internal/xetcas#510) fills the field only when asked, and only for ranges up to 1 GiB.
  • API note: api_changes/update_261004_reconstruction_chunk_byte_sizes.md.

Why

hf-mount (huggingface/hf-mount#246) reads files in bounded fetches of up to 32 MiB, one FileReconstructor each, and xet splits each fetch in 3 reconstruction queries (8 + 16 + 8 MiB). A sequential read therefore makes about 96 CAS queries per GiB (304 for a 3.09 GB file), where a single stream made 3 or 4 per file.

hf-mount already caches reconstruction plans (CachedXetClient) and can derive the plan of a sub-range from a cached plan, but without chunk sizes a derived plan keeps whole terms: up to a 64 MiB xorb range for a small read. With the sizes, the client trims terms at chunk boundaries as the server does. It can then ask for the plan of a window of up to 1 GiB once and derive the plan of each fetch in it locally: about 1 query per GiB instead of 96.

History

This was closed in March together with xetcas#510, over the size of the field (one value per chunk, about 16K per GiB of range) and the server memory for large ranges. xetcas#510 now lists the sizes only for ranges up to 1 GiB, and hf-mount would ask for windows within that limit.

@XciD
XciD force-pushed the feat/chunk-byte-sizes-in-reconstruction-term branch 2 times, most recently from 5aeeff9 to 0d63046 Compare March 10, 2026 12:18
@XciD XciD closed this Mar 11, 2026
@XciD XciD reopened this Oct 4, 2026
Optional uncompressed size of each chunk of a term, filled by CAS when
the client asks for it. A client that caches the plan of a range
(hf-mount) can then trim terms to chunk boundaries and derive the plan
of a sub-range locally, without fetching whole terms. The field is
skipped when empty, so older servers and clients are unaffected.
@XciD
XciD force-pushed the feat/chunk-byte-sizes-in-reconstruction-term branch from 0d63046 to cc4e943 Compare October 4, 2026 08:30
Add client.reconstruction_chunk_byte_sizes
(HF_XET_CLIENT_RECONSTRUCTION_CHUNK_BYTE_SIZES, off by default). When
set, RemoteClient adds ?chunk_byte_sizes=true to its V1 and V2
reconstruction requests, so that the CAS server fills the new field.
@XciD XciD changed the title feat: add chunk_byte_sizes to XorbReconstructionTerm feat: add chunk_byte_sizes to XorbReconstructionTerm, with a client opt-in Oct 4, 2026
@XciD XciD closed this Oct 5, 2026
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