Pick the safetensors over-read ratio per file and warn on heavy over-read#3474
Merged
copybara-service[bot] merged 1 commit intoJul 15, 2026
Conversation
mridul-sahu
force-pushed
the
feature/safetensors-auto-over-read-ratio
branch
from
July 14, 2026 20:57
e90a622 to
1d95c06
Compare
…read An unset max_over_read_ratio now selects the ratio from each file's planned runs instead of a fixed 2.0. Shardings that already map to few contiguous ranges read with no over-read, while shardings that would fragment into a very large number of small strided reads collapse to whole-span reads. A fixed default cannot serve both: the collapse threshold is the file's span over needed bytes, which varies with the sharding and process topology, and values between the extremes produce both many requests and heavy over-read. The fragmentation hint is replaced by an over-read warning: with the automatic ratio, reading far more than needed indicates the target sharding fragments the checkpoint's byte layout, so the warning points at the sharding rather than at a loader knob.
mridul-sahu
force-pushed
the
feature/safetensors-auto-over-read-ratio
branch
from
July 14, 2026 21:00
1d95c06 to
c144a4f
Compare
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.
Description
Follow-up to #3455. With the sharding-driven safetensors load, no fixed
max_over_read_ratiodefault serves every sharding: the ratio at which the greedy partitioner collapses a file's plan into whole-span reads isspan / needed, which varies with the target sharding and the process topology.Measured on Mistral-7B (8-way axis, real HF headers), the old fixed default of 2.0 lands on both failure modes:
This PR makes
max_over_read_ratio=None(the default) pick the ratio per file from the planned runs, which are already available before any I/O:1 + gaps above the coalesce floor, one pass over sorted runs). At or under 1024 reads, use1.0— contiguous shardings read exactly the bytes they need. Above it, use the file'sspan / needed, which collapses the fragmented plan into whole-span reads fetched as concurrent fixed-size chunks.An explicit
max_over_read_ratiofloat keeps exactly the previous fixed-cap behavior.Type of change
Checklist
CHANGELOG.mdunder the[Unreleased]section (or the relevantcheckpoint//export/changelog).