Repository navigation
Conversation
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.
Fix the BF16 MegaMoE forward timeout when training reserves SMs for communication. A partial grid now uses one scheduling queue; a full grid retains locality-domain scheduling. The dispatch policy still reserves eight SMs on B300, and this adds no public flag.
Prior work: #24 adds BF16 SiTU, #25/#26 remove gate/up packing, and #14 reserves SM headroom to avoid collective/grid resource cycles. This fix preserves the reservation and corrects the BF16 scheduler behavior with a partial grid. Stacked on #26 (
ca14ba4); trainer/prefetch integration: https://github.com/fw-ai/fireworks/pull/68620. Only the BF16 forward host specialization and its scheduling-domain selection change. FP8/MXFP4 kernels and backward code are unchanged.The first routed layer of the existing K3.1 shrink YAML timed out at 65,536 tokens/rank with both prefetch policies. Capturing that layer's route IDs reproduces the failure in the standalone production DeepEP/MegaMoE comparison, without FSDP or activation checkpointing. Removing active-pool planning still fails. Using all 148 SMs passes; using one scheduling domain at 140 SMs also passes. The scheduler's per-domain warmup assumes balanced scheduler participation, which a partial grid does not guarantee. Physical SM placement was not instrumented; the controls isolate the locality scheduling path.
Validation on B300 / torch 2.11 /
codex-kda-eager-cache:20261015, trainer commit71629655df5c34f58c9bc62e5faef5aeb66b13cd:k31_shrinkYAML completes a 128K CP2/EP2 optimizer update with full AC, including all 15 routed forwards, 15 recomputations and 15 backwards per rank. Finite loss 13.64055443; first-step compilation/diagnostic time is excluded from benchmarks.MoE-only measurements include production weight merge, dispatch/combine, expert forward/backward, route gradients and LoRA factor gradients. They exclude router/shared experts, FSDP, attention and optimizer. Same physical GPUs 2/3, EP2, 32,768 tokens/rank, BF16 merged weights/activations, FP32 scores, 8-SM reservation, NCCL channels 8/NVLS disabled. Each backend has two fresh runs with 20 warmups + 50 samples; reverse-order repetition. Timing is the median of 100 rank-max samples; memory is the maximum rank/run peak.
This correctness fix costs 2.24% combined latency relative to the parent on this passing 32K workload, with identical GPU allocated/reserved and driver-pinned peaks. Fixed MegaMoE is 1.205× faster forward than DeepEP but 3.75% slower combined; this PR makes no overall training-speedup claim. Driver-pinned accounting excludes OS/RDMA pins.
Both traces have 97 GPU kernels per measured iteration, including the same two communication kernels. No allocation, kernel launch, collective or device synchronization is added. There is no new Python work; the host adds a comparison against cached physical device properties. The new queue policy is a compile-time specialization. Native source/build checksums, diagnostics, full logs, traces and memory snapshots are in the GCS evidence bundle, particularly
bundle/analysis/partial-grid-*,runs/k31-route-replay-*, andruns/k31-partial-grid-traces/.Reproduce native compile coverage:
In the pinned trainer checkout/image with this native package on
PYTHONPATH, checknvidia-smi, select two free GPUs, then run:The uploaded harnesses include
matched_routed_moe.py --route-ids-files ...for the captured regression,run_partial_grid_benchmarks.shfor the measured comparison, andrun_partial_grid_traces.shfor fresh captures. They require updating the container/GPU mapping for a different host and refuse occupied GPUs.Matched MoE-only comparison at EP4
Same physical B300 GPUs 2,3,6,7; H3584/I3072/E128/top8/rank32; 32,768 tokens/rank, EP4. Both backends use BF16 weights/activations, FP32 route scores and production MXFP4 weight merging. Includes dispatch/combine, expert forward/backward, route-score gradients and factored LoRA gradients. Excludes router/shared experts, attention, FSDP, AC and optimizer. Eight SMs reserved; NCCL channels 8, NVLS disabled.
Fresh-process ABBA order (DeepEP, MegaMoE, MegaMoE, DeepEP), each with 20 warmups + 100 samples. Timing is the median of 200 rank-max samples/backend; memory is the maximum rank/run peak.
Forward is 1.374× faster, combined latency 3.81% lower, and backward 20.28% slower. GPU allocated/reserved peaks decrease 28.4% / 42.0%; driver-pinned counters report zero errors. The backward-performance target remains outstanding.
Production-shape reference comparison: minimum score/kernel/factor-gradient cosine 0.9999997711, repeated forwards exact on both backends. The EP4 suite also passes 78 cases on each rank, no skips, minimum printed cosine 0.999993627; fresh-cache length audit adds or modifies zero cubins at lengths 1,37,129,0,7 after two initial variants per rank.
Reproduce with
bundle/harness/run_partial_grid_ep4.shandrun_partial_grid_ep4_length_audit.sh. All four-rank verification outputs and 400 timed iterations are underruns/k31-partial-grid-ep4-benchmark/; summaries arebundle/analysis/partial-grid-ep4-*. This EP4 operator measurement is separate from the pending CP8/EP4 full-model run.256K reduced-topology full-stack qualification
The existing
k31_shrinkYAML/checkpoint completes 20 updates on both backends at 256K, CP2/EP2, using the same physical B300 GPUs 2/3, rank/alpha32, full AC and seeded synthetic data. This comparison includes the entire MegaMoE/prefetch stack. Timing is median rank-max CUDA duration over steps 7–20; memory peaks include all updates/ranks. Each backend uses a fresh process. Both start at loss 13.64192200, and every update/loss is finite.Measured combined latency is 2.4% lower, allocated GPU peak 21.0% lower, and reserved peak 23.2% lower. Backward time is essentially unchanged. Driver-pinned accounting reports zero errors. These two-GPU results leave the requested CP8/EP4 qualification outstanding.
Reproduction:
bundle/harness/run_partial_grid_shrink256.sh; raw inputs/configurations and all per-rank updates:runs/k31-partial-grid-shrink-cp2-262144/. Separate fresh profile processes each completed four warmup updates plus two captured updates. All four traces and four allocator snapshots per backend are underruns/k31-partial-grid-shrink-cp2-262144-traces/. In the MegaMoE rank-0 step-6 trace, 17 forward-prefetched and 17 backward-prefetched all-gathers overlap compute for 89.0% / 29.1% of their kernel time, respectively; overlap between all-gathers and persistent MegaMoE grids is 0 ms. The trace audit and stream-lane picture arebundle/analysis/partial-grid-shrink-cp2-262144-prefetch.{json,png}.256K CP4/EP2 with expert FSDP degree 2
Both backends complete all 20 updates at 256K CP4/EP2 on the same four B300 GPUs (2,3,6,7), using the existing YAML/checkpoint, rank/alpha32, full AC, and the same seeded synthetic data. MegaMoE ran first, then DeepEP, in fresh processes. This reproduces the previously failing topology with the partial-grid scheduler fix. Timing is median rank-max CUDA duration over steps 7–20; peaks include all updates/ranks.
Combined latency is 0.61% lower in this pair. Forward improves 3.42%, while backward is 0.82% slower. GPU allocated/reserved peaks are 21.2% / 22.3% lower; host RSS is 2.2% higher. Driver-pinned accounting reports zero errors. Both begin at loss 13.64190102; all four ranks agree on every finite loss.
Reproduction:
bundle/harness/run_partial_grid_shrink256_cp4.sh; raw steps/configurations:runs/k31-partial-grid-shrink-cp4-262144/. Final CP8/EP4 qualification remains outstanding.Fresh profile processes each complete four warmup and two captured updates. The step-6 audit across all four MegaMoE ranks finds 15 expert forward-prefetched and 14 expert backward-prefetched all-gathers per rank, owned by
layers.N._checkpoint_wrapped_module.moe.experts. Compute overlaps 95.5–99.8% forward / 99.6–99.9% backward of these expert all-gather kernel durations. All-gather overlap with persistent MegaMoE grids is 0 ms on every rank. Evidence:bundle/analysis/partial-grid-shrink-cp4-262144-prefetch.{json,png}andruns/k31-partial-grid-shrink-cp4-262144-traces/.All 16 compressed traces and 16 allocator snapshots parse/load successfully; validation inventory is
bundle/analysis/partial-grid-shrink-cp4-262144-capture-validation.json.Remaining qualification: the requested 256K CP8/EP4, 20-update before/after run needs eight free GPUs. The backward-performance target remains unresolved. Whole-model attention/residual gradient variability also occurs in unchanged parent repeats and remains under investigation; the routed-expert gradients and isolated score/kernel checks meet the strict threshold. Reduced topologies do not substitute for the final eight-GPU run.