Repository navigation
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6715c4a. Configure here.
hanouticelina
left a comment
There was a problem hiding this comment.
mostly looks good to me! i asked an agent (Opus 5.5) to run some benchmarks and here's what it found:
Streaming Xet files with
block_size=0is much slower to start: the first bytes come back after 9–27s with 0.4–2GB peak memory, vs under 1s and 55MB on main.datasetsstreams WebDataset this way (iter_archiveopens each tar withblock_size=0and reads it withtarfile"r|*"), so every shard would wait that long before its first sample. Reading a whole small file is slightly slower too (1.8s vs 1.6s for 21MB).hf_xet1.7.0 behaves the same, and loweringHF_XET_RECONSTRUCTION_MIN_RECONSTRUCTION_FETCH_SIZEfrom 256MB to 16mb only brings the tar case down to 5–6s (the 2GB parquet still takes 15–16s).
block_size=0readmain PR, hf_xet 1.6.0 PR, hf_xet 1.7.0 First sample of a 488MB WebDataset tar 0.88–0.93s, 56MB 16.5–25.7s, 579–705MB 17.0–18.3s, 652–693MB First 4 bytes of a 2.15GB parquet 0.53–0.75s, 55MB 9.2–26.7s, 365–2043MB 12.9–25.4s, 419–1944MB Whole 21MB parquet 1.56–1.70s, 99MB 1.78–1.84s, 130MB 1.78–1.90s, 131MB Time and peak RSS, min–max over 3 runs, each in a fresh process. PR head
eb02168avs main50f5b91f, Python 3.13, Apple M3 Max.
with these numbers, maybe we should keep streaming on HTTP for now and ship only the range reads, and switch once download_stream returns the first bytes quickly? wdyt?
also, since the dataset viewer already runs the v1.33 backport in prod, have you seen any impact there?
|
I can't see a difference in the viewer throughput (jobs/sec) so it must be negligible in the back end side and yea +1 on streaming, it would be cool to improve it before replacing http |
|
Didn't look closely at the implementation but ran into this while benchmarking Zephon, DatologyAI's training data loader, on Hub datasets. Currently at startup, every rank reads every Parquet footer to get per-file row counts. Each footer is a range GET on
IIUC, that's more than the Free (5,000) and PRO (12,000) limits per 5-minute window which may cause issues loading data early on. With this PR, the same footer reads through |
|
a simple fix for them would be to get the metadata once per node instead of per rank, i.e. get them from the main process instead of from every dataloader process |
|
I've opened https://github.com/huggingface/xet-core/pull/1061/changes, this gives better perf for streaming |

HfFileSystem.get_filealready downloads Xet files withhf_xet(#4990), but range reads (HfFileSystemFile._fetch_range) and streaming reads (HfFileSystemStreamFile) still send a GET to theresolveURL. For a Xet file, the Hub redirects that GET to the Xet bridge, which reconstructs the bytes server side. This is the pathdatasetsstreaming and pyarrow/parquet range reads take today.This PR reads these files from Xet storage directly when the file has a
xet_hash:HfFileSystem._read_xetstreams the bytes[start, end)of a file withhf_xetdownload_stream.get_xet_session()returns a new session, afterabort_xet_sessionor in a forked process. AKeyboardInterruptduring a read aborts the session, likexet_get.HfFileSystemFile._fetch_rangejoins the stream for the requested range.HfFileSystemStreamFilestreams fromself.loc, so the existing retry (reopen at the current position) works the same way. It needs the file hash and size, so it now callsinfo()(often served from the dircache) whenhf_xetis available. When the read position is at the end of the file, it returnsb""without a request, like the HTTP 416 case.xet_download_group_kwargsinutils/_xet.pyholds the connection arguments (endpoint, cached token, refresh route, headers without auth), now shared byxet_getand the stream group.Files without a
xet_hashkeep the HTTP path.hf_xet>=1.6.0is already required, andnew_download_stream_group/download_streamexist in 1.6.0.The two stream tests that checked
f.responsenow check the stream iterator, so they cover both paths.Note
Medium Risk
Changes how datasets streaming and parquet-style range reads fetch Xet files, with new shared stream-group caching and fork/session edge cases; HTTP fallback remains for files without
xet_hash.Overview
HfFileSystem now reads Xet-backed files through
hf_xetfor range reads and streaming, instead of HTTP GETs to the Hub resolve URL (which previously hit the Xet bridge server-side).When a file has an
xet_hash,HfFileSystem._read_xetstreams[start, end)viadownload_stream. Buffered opens use this in_fetch_range; stream opens (block_size=0) wire_open_connectionto the same path, with existing retry behavior keyed off_stream_iteratorrather than the HTTPresponse. Stream groups are cached per process and repo revision (_xet_stream_groups), rebuilt on session/token change or afterabort_xet_sessiononKeyboardInterrupt; the cache key includes PID for fork safety.xet_download_group_kwargsinutils/_xet.pycentralizes Xet connection/token kwargs (cached per revision);xet_getnow uses it instead of inliningrefresh_xet_connection_infoand header stripping. Non-Xet files keep the HTTP path unchanged.Tests assert Xet is used for range/stream reads without HTTP mocks, and stream retry tests target
_stream_iterator.Reviewed by Cursor Bugbot for commit eb02168. Bugbot is set up for automated code reviews on this repo. Configure here.