Skip to content

[2/3] feat(training): online cost-aware scheduling - #987

Open
yushengsu-thu wants to merge 7 commits into
sgl-project:mainfrom
yushengsu-thu:cost-aware/2-online
Open

yushengsu-thu wants to merge 7 commits into
sgl-project:mainfrom
yushengsu-thu:cost-aware/2-online

Conversation

@yushengsu-thu

@yushengsu-thu yushengsu-thu commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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-0 RefDistributor sorts 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 records valid_anchors on each ref.

Online, Qwen3-8B, 2 capture servers + DP2 on 4x H200, samples/s (setup):

baseline cost-aware
DFlash 10.80 11.95 +10.6%
DFlash2 11.43 12.24 +7.1%
DSpark 15.43 16.81 +8.9%
Domino 20.97 21.72 +3.6%
P-EAGLE, bs 1 14.27 14.74 +3.3%
EAGLE3, bs 1 9.62 9.56 -0.6%

…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.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 03:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants