[MoE] Add AutoEP routing replay (#8634)
## Problem
AutoEP activation-checkpoint recomputation reruns router top-k selection
even when rollout or training already has expert assignments. Replaying
those assignments removes the second routing decision while keeping the
current gate scores in the gradient path.
## Change
- Add opt-in per-model `RoutingReplay` state for record, replay, and
imported route IDs.
- Let `TokenChoiceTopKRouter` reuse stored routes while preserving
gate-score gradients.
- Validate route shape, integer dtype, expert range, and duplicate
experts; copy imported route buffers.
- Document checkpoint and external-route usage and their token-order
requirements.
## Validation
Validated on 2x NVIDIA A100 80GB PCIe with PyTorch 2.8.0+cu128.
- 7 targeted routing-replay and checkpoint tests.
- `tests/unit/v1/moe/test_autoep_unit.py`: 196 passed, 1 skipped.
- Checkpoint replay outputs and input/parameter gradients matched the
reference at `rtol=1e-5`, `atol=1e-6`.
- 3 two-rank AutoEP integration tests covering external route replay,
ZeRO-2 training, and ZeRO-3 placement. The external-route case uses
EP=2, two AutoEP layers, `1x8x64` activations, and an `8x2` int16 route
buffer.
- Pre-commit, `compileall`, and `git diff --check` passed.
The external route API accepts flattened `[tokens, top_k]` routes in
training-forward order. Packed and sequence-parallel route remapping is
not included. Checkpoint routes are consumed FIFO per layer.
---------
Signed-off-by: HR-zengzzz <hrzeng123456@gmail.com>
Signed-off-by: Silas-Zeng <1784012765@qq.com>
Signed-off-by: Masahiro Tanaka <tanaka.masahiro@gmail.com>
Co-authored-by: Masahiro Tanaka <tanaka.masahiro@gmail.com>