Uh oh!
There was an error while loading. Please reload this page.
DsBatchSampler: probe-epoch auto cap + fail-fast OOM ordering - #327
Open
yxlllc wants to merge 1 commit into
Open
DsBatchSampler: probe-epoch auto cap + fail-fast OOM ordering#327yxlllc wants to merge 1 commit into
yxlllc wants to merge 1 commit into
Conversation
KakaruHayate added a commit
to KakaruHayate/DiffSinger
that referenced
this pull request
Aug 25, 2026
KakaruHayate added a commit
to KakaruHayate/DiffSinger
that referenced
this pull request
Aug 25, 2026
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 freeto 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
DsBatchSamplerre-groups samples into batches on every epoch, so the batchgeometries differ across epochs. A batch appearing in a later epoch can exceed
anything seen in epoch 0 while still respecting
max_batch_frames. Since theCUDA caching allocator grows segment-wise and never shrinks, such a batch can
lock in a permanently larger reserved footprint — or OOM — several epochs into
a run that looked stable.
This PR turns epoch 0 into a memory probe epoch:
Fail-fast ordering — on the probe epoch, batches are served in strictly
decreasing padded-frames order, so the most memory-hungry batch runs at the
very first steps. If the configuration does not fit, the run fails at the
start of training instead of several epochs in.
Auto-capped batching — the probe epoch's measured maximum padded-frames
becomes the effective
max_batch_framesfor all subsequent epochs. Everylater grouping is therefore bounded by a geometry already proven to fit.
Because the allocator's reserved high-water mark is path-dependent and only
grows when a step introduces demand beyond anything seen before, the epoch-0
peak becomes a hard upper bound for the rest of training — no late-epoch
reserved-memory growth, and no late-epoch OOM from novel batch shapes.
DDP behavior
No communication is needed: the batch pool and the cap are pure functions of
the dataset sizes and the epoch-seeded RNG (seeded identically on all ranks),
so every rank independently derives the same cap. The probe sort happens before
per-rank assignment, hence each rank's worst batch still lands in its first
steps, and fail-fast holds for DDP.
Compatibility
Gated behind
probe_and_cap_max_frames(defaultFalse) and enabled for thetraining dataloader only. With the flag off, batch streams are bit-identical to
before, including the validation sampler (its non-shuffled paths never touch
the RNG).
drop_lastand leftover/padding assignment are unchanged and onlyever operate on already-capped batches. Sampler state is not serialized, so
resuming from a checkpoint re-probes deterministically.