Skip to content

feat(runtime): balance complete consumer optimizer windows by estimated cost - #966

Merged
maocheng23 merged 7 commits into
mainfrom
codex/pr942-10-consumer-dispatch
Oct 22, 2026
Merged

maocheng23 merged 7 commits into
mainfrom
codex/pr942-10-consumer-dispatch

Conversation

@jiapingW

@jiapingW jiapingW commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Uneven anchor/context work makes consumer ranks wait at optimizer boundaries. Add opt-in cost-based consumer dispatch while retaining round_robin as the default.

  • cost_balanced: group similar samples into microbatches and balance rank loads within each original optimizer window.
  • two_window_bucketed: group samples across two complete windows, then balance each window.
  • two_window_joint_balanced: balance two windows jointly, accepting the proposal only when its estimated total critical-path cost is lower than independent balancing.

Capture valid-anchor counts in reference metadata, with token-length fallback for older references. Two-window policies require a high watermark covering two global optimizer windows. Dispatch preserves sample coverage, equal per-rank accumulation counts, deduplication, durable acknowledgements, and incomplete-tail handling. Cross-window regrouping changes optimizer-step membership and can change the training trajectory.

This PR targets main directly and contains only consumer dispatch and its configuration, metadata, documentation, and tests. DSpine and the former attention/projection stack are not prerequisites. Adapted from #942; related to #955. The downstream #967 branch needs a separate restack onto this rewritten branch.

Validation: 176 tests passed on H20 using Python 3.12. Coverage includes dispatch, server capture, configuration, recipe wiring/documentation, package architecture, streaming references, and two-process DDP accumulation. Black 24.10.0, isort 5.13.2, and git diff --check passed.

The cost model and fixed two-window lookahead are heuristics. No end-to-end throughput or downstream accuracy benchmark was run; lower estimated cost does not guarantee lower wall-clock time. Buffering two windows can increase startup waiting and retained-feature memory.

@jiapingW
jiapingW force-pushed the codex/pr942-10-consumer-dispatch branch from ff15381 to cb2ca89 Compare October 14, 2026 09:00
@jiapingW
jiapingW force-pushed the codex/pr942-09-dspine branch from b1705cf to b326574 Compare October 14, 2026 09:00
@jiapingW jiapingW changed the title [10/11] feat(runtime): balance complete consumer optimizer windows by estimated cost [9/10] feat(runtime): balance complete consumer optimizer windows by estimated cost Oct 14, 2026
@jiapingW
jiapingW force-pushed the codex/pr942-10-consumer-dispatch branch from cb2ca89 to aa8d222 Compare October 14, 2026 09:45
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
… into the MoE 8-expert experiment branch

Brings is_causal (configurable draft attention range/direction), dspark_flatten_projection /
dspark_cache_projection, ddp_bucket_cap_mb, the DDP once-per-window synchronization (sgl-project#958, which
replaces this branch's prepare_micro_step fix; the matching test is dropped), the removal of the
implicit qwen3-instruct system prompt (sgl-project#959), balanced consumer optimizer windows (sgl-project#966) and the
DSpine algorithm. Conflicts in specforge/training/backend.py and controller.py were resolved in
favour of the PR.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…izer quanta in flight

Restores the 3.5 s/step measured with these two scheduling settings; neither changes the optimizer
windows' sample membership or the loss.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
… cost-balanced consumer dispatch with the 4-quanta in-flight window

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
… optimizer quanta in flight

Co-Authored-By: Claude Fable 5.1 <[email protected]>
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Oct 15, 2026
…l-project#963 + sgl-project#966) into the MoE experiment branch

The same upstream content was already merged here independently; this records the fork branch's
current head as an ancestor. The two MoE config files that spark-Qwen3-8B also carries are kept in
this branch's version (the one the running experiment uses).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@maocheng23
maocheng23 force-pushed the codex/pr942-10-consumer-dispatch branch from aa8d222 to 3aac14a Compare October 21, 2026 21:54
@maocheng23
maocheng23 changed the base branch from codex/pr942-09-dspine to codex/pr965-04-performance October 21, 2026 21:56
@maocheng23
maocheng23 changed the base branch from codex/pr965-04-performance to codex/pr942-09-dspine October 21, 2026 22:09
@maocheng23
maocheng23 force-pushed the codex/pr942-10-consumer-dispatch branch from 3aac14a to aa8d222 Compare October 21, 2026 22:10
@maocheng23
maocheng23 force-pushed the codex/pr942-09-dspine branch from 244e31d to b326574 Compare October 21, 2026 22:10
Comment thread examples/configs/README.md Resolved
Comment thread specforge/training/DESIGN.md Resolved
Comment thread specforge/launch.py Resolved
@jiapingW
jiapingW force-pushed the codex/pr942-09-dspine branch from b326574 to dbacebb Compare October 22, 2026 03:03
@jiapingW
jiapingW requested a review from zyksir as a code owner October 22, 2026 03:03
@jiapingW
jiapingW force-pushed the codex/pr942-10-consumer-dispatch branch from aa8d222 to 7aad50d Compare October 22, 2026 04:47
@jiapingW jiapingW changed the title [9/10] feat(runtime): balance complete consumer optimizer windows by estimated cost feat(runtime): balance complete consumer optimizer windows by estimated cost Oct 22, 2026
@jiapingW
jiapingW changed the base branch from codex/pr942-09-dspine to main October 22, 2026 04:47

@maocheng23 maocheng23 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, good work!
Please merge after CI is passed

@maocheng23
maocheng23 merged commit 3d9ef85 into main Oct 22, 2026
7 of 8 checks passed
@maocheng23
maocheng23 deleted the codex/pr942-10-consumer-dispatch branch October 22, 2026 08:03
yushengsu-thu added a commit to yushengsu-thu/SpecForge that referenced this pull request Nov 9, 2026
…l-project#966 (consumer dispatch) onto 475c9b9

Speed-only changes so the dense-6144 run carries the same loss kernels as the dense-1/8 5-epoch run (cde2f05):

- sgl-project#961, fused FP32 CE + teacher L1 at logits level: 158cfdd, b0bd4f6, b525e15
  (training.fused_logits_loss defaults to true, training.objective_checkpointing to true)
- sgl-project#966, cost-balanced consumer dispatch and backpressure fixes: 7aad50d, c124809, c59e3bf,
  70061c0, 4f4c4fa, 1e1a4b9, a607703 (runtime.consumer_dispatch stays round_robin)

Conflict resolutions against this branch: schema.py and examples/configs/README.md take only the
fused_logits_loss lines (no ddp_bucket_cap_mb, which belongs to sgl-project#958); dflash_family_model.py keeps
the MoE hooks _take_moe_aux_loss_and_log and on_optimizer_step next to the renamed
_selector_token_terms; tests/test_config/test_schema.py keeps the tri-state Liger test and drops the
ddp-bucket test.

Measured on the dense-6144 run (8x B200, one capture server + six trainers): train compute
2.39 -> 1.99 s/step; objective benchmark (8192 tokens, checkpointing on) 130.8 -> 74.7 ms per
micro-step with identical loss.
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