From Files to Chunks: Improving HF Storage Efficiency
Hugging Face's Xet team plans to replace file-level Git LFS storage with content-defined chunking (CDC), where a rolling hash over a sliding window sets variable-size chunk boundaries and chunks are deduplicated in a content-addressed store, so edits only upload and store changed chunks. A prior XetHub benchmark on the CORD-19 dataset showed roughly 50% gains, with storage dropping from 8.9 GB to 3.52 GB and download time from 51 to 19 minutes. On two versions of GPT-2's safetensors file, CDC cut total storage by 53%. Fine-tuned models and checkpoints show 30-85% dedup ratios, which could save about 100 TB immediately, and Xet-backed repos are targeted for early 2025.
Related posts
- From Chunks to Blocks: Accelerating Uploads and Downloads on the Hub
Hugging Face mediumAdeptHugging Face's Xet storage backend uses content-defined chunking for deduplication but avoids per-chunk overhead by aggregating chunks into content-addressed blocks of up to 64MB and using shards to map files to chunks. That cuts CAS entries roughly 1,000x. A global index over key chunks, a 0.1% subset picked by hash modulo, exploits spatial locality to find shards for deduplication without a network query per chunk. On a 191GB repo of 29 Gemma-2-9B GGUF quantizations, only about 97GB of unique blocks were stored, nearly halving upload time. Local chunk caching also avoids re-downloading unchanged data.
- Xet is on the Hub
Hugging Face mediumAdeptHugging Face migrated its first model and dataset repositories from Git LFS to Xet storage, which uses content-defined chunking (~64 KB chunks aggregated into ~64 MB blocks) so that only changed bytes are uploaded. The migration moved 4.5 TB and ~6% of Hub download traffic in one day and exposed two production issues. First, unaligned range requests from hf_transfer forced CAS to stream whole blocks, a 4:1 read amplification. Adding chunk-length metadata to the block format fixed this and cut GET latency ~35%. Second, unflushed page cache during uploads caused disk throttling and pod load imbalance, which was mitigated with per-pod concurrent upload limits. The core lesson is that incremental migrations of real traffic surface problems test environments can't.
- Migrating the Hub from Git LFS to Xet
Hugging Face mediumAdeptHugging Face moved 500,000 repositories and about 20 PB from Git LFS to its Xet content-addressed storage with almost no user disruption. Two pieces made that possible. A Git LFS Bridge lets older clients keep working by returning presigned URLs and reconstructing files from chunks in S3. A webhook-driven background pipeline, with an orchestrator batching files into jobs of 1,000 files or 500 MB for worker pods, migrates LFS content without locks. Scaling to multi-petabyte accounts exposed three problems: a cross-mount `/tmp` move bug that filled disks, an undersized CAS, and network/EBS I/O bottlenecks on the workers. After fixes, CAS throughput rose from about 35 Gb/s to peaks near 300 Gb/s.
- Rearchitecting Hugging Face Uploads and Downloads
Hugging Face mediumAdeptHugging Face's Xet team is replacing the Hub's direct-to-S3 uploads and CloudFront downloads with a content-addressed store (CAS) built on "dumb reads, smart writes": reads fetch reconstruction info from CAS, and writes are chunked, deduplicated and validated before reaching S3. Byte-level handling gets around CloudFront's 50GB file limit, enables format-aware dedup and compression for Parquet and Safetensors, and adds audit telemetry. Analysis of 8.2M upload requests (130.8 TB from 88 countries) in one day showed the top 7 countries produce 80% of bytes, so CAS nodes will run in three AWS regions: us-east-1 and eu-west-3 with 4 nodes each, and ap-southeast-1 with 2. Hugging Face accepts an estimated 12% drop in aggregate first-hop bandwidth, expecting other optimizations to offset it.
- Parquet Content-Defined Chunking
Hugging Face mediumAdeptParquet Content-Defined Chunking, now available in PyArrow and Pandas via the use_content_defined_chunking option, writes Parquet data pages so that small logical edits produce minimal byte-level differences. This lets content-addressable storage like Hugging Face's Xet layer deduplicate effectively. On a 100k-row OpenOrca subset, exact re-uploads, added or removed columns, type casts and appended rows already deduplicate well, transferring only the new pages and the footer. Row insertions and deletions defeat vanilla Parquet, though, because separately compressed pages shift: about 90 MB of 99 MB was re-uploaded. CDC aligns page boundaries to content to fix this and also handles different row-group sizes and file splits.