Add an opt-in fused weighted restore for AutoEP (#8326)
## Summary
- Add an opt-in AutoEP `combine_impl="fused_weighted_sum"` path while
keeping the existing eager weighted reduction as the default.
- Restore `[tokens * top_k, hidden]` expert rows directly to `[batch,
sequence, hidden]` in one Triton pass with FP32 weighting and
accumulation, including expert-row and routing-score gradients.
- Fail fast for unsupported CUDA/dtype/score/AutoTP/expert-TP
configurations, preserve higher-order autograd through a differentiable
fallback, and document the experimental path.
## Performance
- Canonical-shape H100 microbenchmark: 2.98x forward and 1.87x
forward+backward, saving about 0.215 ms per layer.
- Qwen3-30B-A3B, 48 layers, EP16, 2x8 H100: pooled median improved by
0.97%, with a 95% CI of `[-1.12%, +3.02%]`; this is not yet a
statistically conclusive end-to-end win.
- Peak reserved memory decreased by 96 MiB, matching the removed 64 MiB
FP32 weighted intermediate and 32 MiB assignment buffer.
- The experimental expert reorder was removed after launch-amortized
measurements showed no benefit, so this PR changes only the weighted
restore.
## Testing Done
- [x] Local code review completed
- [x] Unit tests added/updated
- [x] Integration tests pass
- [x] Manual testing performed
- Repository pre-commit hooks passed for all nine changed files.
- H100 fused token-op suite: 23 passed, including top-k 2/4/6/8,
non-power-of-two hidden sizes, input-contract validation,
forward/backward parity, and double backward.
- H100 configuration tests: 5 passed for standard, folded AutoTP, expert
tensor parallelism, and score-application validation.
- Full-step eager/fused parity: 3 passed, covering loss, output, input
gradients, router/expert gradients, optimizer parameter deltas,
activation checkpointing on/off, EP2, and local experts.
- Earlier final restore-only sweep: 121 kernel/config tests passed
before the additional review-driven safety cases were added.
---------
Signed-off-by: yh0903 <helloyu0903@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Hongwei Chen <33092912+hwchen2017@users.noreply.github.com>