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.
Allow BF16 MegaMoE forward to read separate contiguous gate and up weights. Eight-row TMA loads reconstruct the existing interleave directly in shared memory, removing the caller's packing allocation and copies while preserving MMA and SiTU rounding. The optional trailing
l1_up_weightsargument is capability-gated and rejects fused shared experts for this layout.Stacked on #25. Trainer integration PR: https://github.com/fw-ai/fireworks/pull/68548.
B300, EP=1, 32,768 tokens, H=3584/I=3072/E=128/top-8/rank-32. Both arms include the parent separate-weight backward and the capacity-tail correctness fix. Alternating A/B/B/A blocks use 20 warmups and 41 samples each (82 samples per arm); memory uses separate fresh processes.
Primitive scope excludes base-weight merging, router/latent/shared experts and communication. Forward is 28.0% lower and combined time 10.3% lower; this is not an end-to-end speedup claim. CUDA host accounting has zero errors and excludes OS/RDMA pins. Two-iteration traces show 16 forward copy kernels (13.137 ms total) before and zero after; total kernels fall from 500 to 484. NCU after: SM throughput 80.2%, tensor cycles 78.3%, DRAM active 31.5%; replay durations are excluded from timings.
Validation: 58 CPU tests; 62 CUDA compile variants; 23 new-layout EP1 GPU cases and 69 EP2 cases per rank across packed/backward-only/both-separate layouts. Real shrink dimensions pass the matching BF16 SiTU oracle: forward bitwise equal, dx cosine 0.999992312, router cosine 1, all six factors >=0.999999916. Repeated forwards are bitwise deterministic. Empty/odd/all-masked, shared factors, AC and input-offload cases pass. Fresh-cache length audit: two initial modified variants, zero additions or changed cubins for lengths 1,37,129,0,7.
Reproduce correctness in the trainer environment with this native build:
Review: no new host/device synchronization or collectives. The wrapper adds a capability check and keyword argument and removes stack/copy work; trace launch counts confirm fewer GPU launches. Native TMA requests increase within the existing kernel, with unchanged barrier byte counts, SMEM layout and accumulation order. No new environment variables or public API/schema changes.
Fresh full-model qualification (existing real
k31_shrinkYAML, rank/alpha32, full AC, CP2/EP2, 64K tokens):Timings use rank-0 medians over steps7–20; peaks are maximum over ranks. This is ~1% full-step improvement and ~12% lower allocated peak, not the requested 1.5–2× training gain. Host RSS is slightly higher. Final 256K/CP8/EP4 remains unrun. A fresh 1K control of this forward optimization completes 20 steps in each arm, 1.034→1.001 s median combined CUDA time and 44.212→43.892 GiB allocated peak; DeepEP at 43.644 GiB is still lower.
EP4 qualification also passes all 69 cases on each of four ranks, minimum recorded cosine 0.999993627. Full-model cross-backend expert gradients reach ~0.9999893 and do not meet a universal all-parameter 0.99999 gate; residual/attention adapters are lower still. Isolated matching kernel-oracle checks pass, and no stronger full-model parity claim is made.
Remaining qualification is explicit: the real existing
k31_shrinkYAML completes 20 updates at 1K/CP2/EP2, but 43.892 GiB allocated peak remains above the 43.644 GiB DeepEP baseline. Full-model AC comparisons also show projection-adapter gradient cosines below 0.99999 on both backends; isolated expert/kernel checks pass. Final 256K/CP8/EP4, and complete end-to-end performance/memory acceptance remain pending. Evidence bundle:profile/k31-megamoe-merged-lora-20261027/(uploaded; link below).Native compile-only check:
python tests/compile_mega_moe_compat.py --output-dir /tmp/mega-forward-compile(62 variants; requires nvcc/CUTLASS, no GPU).Actual model-input operator check and fresh 64K captures
Captured all three routed MoE boundaries from a real CP2/EP2 native-MXFP4 model backward (documents 1/65/257, H=I=512, E=128, top-8, shared rank/alpha32 factors), then replayed each with the unchanged matching grouped reference and exactly the captured upstream adjoint. All three forwards are bitwise identical; minimum input-gradient cosine is 0.9999907997, minimum factor-gradient cosine 0.9999959057, and router gradients exceed 0.99999999999999. Every operator meets the strict >0.99999 gate. The capture wrapper preserves production aliasing and does not unpack saved tensors a second time. It synchronizes CPU copies and is numerical evidence only.
This does not replace or hide the reported full-model gradient differences across backends/AC settings. Fresh final-code 64K CP2/EP2 runs also completed six successful updates with step-5/6 traces and memory snapshots on both ranks (8 artifacts). The 20-step timing/loss comparison above remains the performance result; profiled timings are separate. Local report:
analysis/cp-model-moe-boundary-comparison.json; trace inventory:analysis/cp2-65536-final-code-trace-inventory.json. Final CP8/EP4 256K remains pending.Uploaded evidence
The completed local test, benchmark, NCU, trace and memory-snapshot bundle is uploaded to
gs://fireworks-fine-tuning-profiles/kimi-k31/yued/20261027-megamoe-merged-lora/(browse artifacts).bundle/analysis/artifact-manifest.jsonmaps local evidence paths to GCS objects; transfer checksums and remote object sizes were verified. The required final 256K CP=8/EP=4 run still needs eight free GPUs and is not included.