Repository navigation
[2/3] feat(training): online cost-aware scheduling - #987
Open
yushengsu-thu wants to merge 7 commits into
Open
yushengsu-thu wants to merge 7 commits into
yushengsu-thu wants to merge 7 commits into
Conversation
…ware scheduling DSpark historically averages every DP micro-batch round by its own all-reduced token weight (`round`). Cost-aware scheduling regroups rounds by cost, which would make that normalization re-weight tokens by round composition, so the model gains a `step` mode: it hands the trainer additive `loss_terms` and the whole optimizer step is averaged by its global token weight, like DFlash, with no per-micro-batch all-reduce. The mode is chosen automatically (`step` with `training.cost_aware_scheduling`, `round` otherwise) and recorded in the DSpark resume contract.
Checkpoints written before the DSpark resume contract recorded `dspark_loss_normalization` were trained with the per-round normalization. Treat a missing key as `round` so those runs resume unchanged, while a resume that now resolves to `step` (cost-aware scheduling on) is still rejected.
One optimizer window is sorted by a per-sample cost key, cut into DP rounds of similar cost, and each rank takes one contiguous slice. The planner is pure Python so the online dispatcher and the offline sampler can share it.
…ithm scheduling keys `training.cost_aware_scheduling` enables cost-balanced DP rounds; `training.cost_aware_key` picks the per-sample cost (`length`, `anchors`, or `auto` for the key each algorithm declares in its capabilities: `anchors` for the DFlash family, `length` for EAGLE3, P-EAGLE and MTP). The application layer rejects algorithms without a key, EAGLE3 above batch size 1 (its loss is a per-micro-batch mean), and the anchors key on non-anchor objectives. With scheduling on, DSpark resolves to its per-step loss normalization.
The capture producer counts the positions whose own and next token are supervised (the DFlash-family anchor rule) from the prompt's loss mask and stores the count in the ref metadata, next to num_tokens, so the online consumer can schedule by anchors without touching the features.
…-balanced rounds With a scheduling policy the rank-0 distributor plans every secured optimizer window with the shared planner and publishes its rounds to the per-rank inboxes in planned order, so each round holds samples of similar cost. Inboxes are consumed in publish order, so the ack and backpressure accounting is unchanged. A window whose refs carry no anchor count is scheduled by length, and one without any usable cost keeps arrival order. The online consumer records the policy in its checkpoint contract; older checkpoints without the key resume with scheduling off.
yushengsu-thu
requested review from
FlamingoPg,
FrankLeeeee,
shuaills and
sleepcoo
as code owners
October 17, 2026 03:21
This branch has not been deployed
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.
Part 2/3 of #955. Stacked on #986, so the diff includes it until that's merged (just this part). Offline is in #988.
Adds
training.cost_aware_scheduling. The rank-0RefDistributorsorts each optimizer window by cost (anchors for the DFlash family, length for EAGLE3/P-EAGLE/MTP) and sends similar samples out in the same round, so there's less padding and less waiting on the slowest rank. Each step still gets the same samples, and acks/resume work as before. Capture now recordsvalid_anchorson each ref.Online, Qwen3-8B, 2 capture servers + DP2 on 4x H200, samples/s (setup):