[ROCm][DeepSeek-V4.1-Flash] opt-in routed-expert load counting (VLLM_AKR_EXPERT_COUNTS)
The input of the static expert placement plans (amd_kernels.expert_perm):
with VLLM_AKR_EXPERT_COUNTS=<dir>, every AITER MegaMoE layer counts the
routed (token, expert) pairs of the router's logical ids (before the
placement remap and the shared-expert append) into one persistent GPU
buffer with one Triton launch per layer, so it is CUDA graph safe. Padding
rows (forward-context is_padding) and ids < 0 are not counted; decode-only
and prefill-carrying steps are counted apart (the planner balances both).
A DeepSeek-V4.1 model state subclass marks the step kind in
preprocess_state, so the model runner is untouched. Each DP rank writes
<dir>/expert_counts_dp<rank>.npz every 60 s and at exit.
Unset (the default), get_model_state_cls returns the same class as before
and the MegaMoE forward only tests a bool set at construction. The
variable is left out of the compile hash: DeepSeek-V4.1 on ROCm is not
torch.compiled.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>