Optimize sharded safetensors metadata parsing: 3 HTTP requests → 2 per shard#1979
Open
Optimize sharded safetensors metadata parsing: 3 HTTP requests → 2 per shard#1979
Conversation
Previously, each shard required 3 HTTP requests (fileDownloadInfo + header length + header content). This replaces that with 2 direct range requests (8 bytes for length, then exact header bytes), bypassing downloadFile/ fileDownloadInfo entirely for sharded models. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
…ll shard bodies Cancel the response body and throw a clear error when the server returns 200 instead of 206, which would otherwise attempt to load multi-GB shard files into memory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
coyotte508
reviewed
Feb 16, 2026
Member
There was a problem hiding this comment.
note this means that we're downloading from the xet bridge, instead of downloading from xet backend directly (xet-read-token + reconstructionInfo + cas requests)
maybe faster because of the CDN in front of the bridge? or the bridge being closer to the xet backend? idk
anyway up to you (whether to merge) - cc @XciD for fiz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
downloadFile/fileDownloadInfowhen fetching shard headers, using direct range requests insteadBenchmarks (avg of 10 runs each)
* bloom optimized avg skewed by one 10.8s outlier run (min was 1,581ms vs old min 2,967ms)
Key finding: DeepSeek-Math-V2 (163 shards) fails 100% with old code — 489 HTTP requests (163 × 3) overwhelm the server. The optimized path (163 × 2 = 326 requests) handles it reliably.
Test plan
🤖 Generated with Claude Code