Skip to content

[MoE] Locally compile microbatch auxiliary loss statistics - #5252

Merged
acisseJZhong merged 4 commits into
mainfrom
moe_local_compile
Oct 10, 2026
Merged

acisseJZhong merged 4 commits into
mainfrom
moe_local_compile

Conversation

@acisseJZhong

Copy link
Copy Markdown
Contributor

Summary

  • locally compile the rank-local statistics for MicrobatchWiseLoadBalanceLoss
  • avoid materializing the normalized [T, E] score tensor
  • enable the region by default for DeepSeek V3
  • keep CP/TP reductions and auxiliary-loss injection outside the compiled region

The post-router gather/normalize path was also tested, but is not included: it was 6.5% slower and did not reduce peak memory at the DeepSeek V3 shape.

Performance

Single H100, FP32 router scores, DeepSeek V3 shape (T=8192, E=256, K=8), forward + backward, 10 warmup iterations and 50 measured iterations:

Path Median Speedup Incremental peak memory Memory reduction
Eager 0.274 ms 1.00x 40.06 MiB -
Local compile 0.203 ms 1.35x 8.03 MiB 32.03 MiB (80%)

This measures only the rank-local auxiliary-loss statistics, not end-to-end training.

Numerics

Eager vs local compile on the benchmark shape:

Value Max absolute difference
Expert counts 0
Normalized-score sums 3.814697e-6
Router-score gradient 7.450581e-9

Tests

pytest -q tests/unit_tests/cpu/test_compile_config.py \
  tests/unit_tests/cpu/test_aux_loss.py \
  tests/unit_tests/gpu/test_moe_aux_loss_compile.py

15 passed

The current local PyTorch installation cannot launch the current TorchTitan main training entrypoint because it lacks torch.distributed.pipelining.analyze_pipeline_activation_liveness; end-to-end coverage is left to CI.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 10, 2026
@acisseJZhong
acisseJZhong marked this pull request as ready for review October 10, 2026 01:06
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Oct 10, 2026
@acisseJZhong
acisseJZhong merged commit c9b10b5 into main Oct 10, 2026
tianyu-l pushed a commit that referenced this pull request Oct 13, 2026
## Summary

#5252 enabled a new local_compile region (moe_aux_loss), which shifted
numerics across the models on ROCm. This PR Regenerates the 9 affected
mi350x files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants