Skip to content

[1/3] feat(dspark): per-optimizer-step loss normalization for cost-aware scheduling - #986

Open
yushengsu-thu wants to merge 2 commits into
sgl-project:mainfrom
yushengsu-thu:cost-aware/1-dspark-step-norm
Open

yushengsu-thu wants to merge 2 commits into
sgl-project:mainfrom
yushengsu-thu:cost-aware/1-dspark-step-norm

Conversation

@yushengsu-thu

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

Copy link
Copy Markdown
Contributor

Part 1/3 of #955 (online: #987, offline: #988). This one can be merged on its own.

DSpark normalizes the loss per DP round. Cost-aware scheduling puts similar samples in the same round, so short rounds would get a heavier per-token weight. This adds a step mode that normalizes over the whole optimizer step, like DFlash does. It's only picked when cost_aware_scheduling is on, so nothing changes until #987. round stays bit-identical and old checkpoints resume as round.

step vs round with no regrouping, 4x H200, samples/s. The gain comes from dropping the per-micro-batch all-reduce.

round step
offline, Qwen3.8-27B, DP4 17.0 17.5
online, Qwen3-8B, DP2 19.1 21.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.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 03:20

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