vllm.models.deepseek_v41.amd.akr_eplb
¶
Static routed-expert placement with replicas for the MegaMoE experts of DeepSeek-V4.1-Flash on EP8 (EPLB without the runtime rebalancer).
kernel_config.amd_kernels.expert_perm names a plan .npz (a bare file name
that configs/ next to this module holds is that shipped plan, anything else
a path); unset, nothing here is imported or run. Per MoE layer the plan holds
phys2log[8 * S] (one S per expert family: a 2-D array), the logical
expert of each physical slot; slot p lives on EP rank p // S, the rank-major
physical id that MegaMoE (dest = id // experts_per_rank), the fused EP8
kernel and vLLM's EPLB use. A logical expert may hold several slots
(replicas). Plan keys:
phys2log [L, 8 * S] int, layer_ids [L]: the backbone layers (384 experts)
draft_phys2log [D, 8 * S_d], draft_layer_ids [D]: the DSpark draft layers
(128 experts), optional (absent: identity placement)
world_size: the EP size the plan was made for (default 8)
Weights: DeepseekV4AiterMegaMoEExperts.weight_loader copies a checkpoint
expert into every local slot that holds it (each rank allocates S experts per
layer). Routing: the routers still choose logical ids; right before the
experts run, LayerPerm.remap turns each id e >= 0 into the physical id
l2p[e, hash(token * K + k, layer, rank) % count[e]] (one Triton launch,
graph safe, deterministic, uniform over the replicas); ids < 0 stay.
Classes:
-
LayerPerm–One layer's placement on
worldEP ranks: host tables and their -
Plan–A validated plan file:
layers[n_experts][layer_id] = phys2log.
Functions:
-
check_row–One layer's phys2log: integers,
world * Sslots with -
hash32–Host reference of the kernel's replica hash (idx = token * K + k).
-
layer_index–The decoder layer id of a module prefix such as
-
layer_perm–The placement of the MoE layer named by
prefix, or None (no plan, an -
plan_path–The plan file of
kernel_config.amd_kernels.expert_perm, '' if unset. -
register_aiter_profile–Give MegaMoE's replica-slot geometry (S = 49) AITER's tuned EP8 profile
LayerPerm
¶
One layer's placement on world EP ranks: host tables and their
device copies.
Methods:
-
local_slots–The local slots (of the rank holding slots `[start, start +
-
remap–Logical -> physical ids (a new tensor of the same shape and dtype);
-
remap_reference–Host reference of
remap. -
tables–(l2p int32 [E * R], count int32 [E]) on
device; allocate before
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
local_slots(logical, start, n_local)
¶
The local slots (of the rank holding slots [start, start +
n_local)) that hold logical.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
remap(topk_ids)
¶
Logical -> physical ids (a new tensor of the same shape and dtype); ids < 0 (padding) stay.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
remap_reference(topk_ids)
¶
Host reference of remap.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
tables(device)
¶
(l2p int32 [E * R], count int32 [E]) on device; allocate before
graph capture.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
Plan
¶
A validated plan file: layers[n_experts][layer_id] = phys2log.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
check_row(row, n_experts, world, what)
¶
One layer's phys2log: integers, world * S slots with
S >= n_experts / world, every logical id present.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
hash32(idx, salt)
¶
Host reference of the kernel's replica hash (idx = token * K + k).
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
layer_index(prefix)
¶
The decoder layer id of a module prefix such as
model.layers.7.ffn.experts.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
layer_perm(vllm_config, prefix, n_experts, ep_rank, ep_size)
¶
The placement of the MoE layer named by prefix, or None (no plan, an
identity row, a draft layer the plan leaves out). A plan that does not fit
the model (EP size, expert count, a missing backbone layer) raises.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
plan_path(vllm_config)
¶
The plan file of kernel_config.amd_kernels.expert_perm, '' if unset.
Source code in vllm/models/deepseek_v41/amd/akr_eplb.py
register_aiter_profile(experts_per_rank, hidden, inter)
¶
Give MegaMoE's replica-slot geometry (S = 49) AITER's tuned EP8 profile of this model, which AITER keys on 48 experts per rank only. Must run before the MegaMoE runtimes are built; a no-op for other S, other shapes, or an AITER that already matches S (ROCm/aiter#8453 adds S = 49 to the profile; drop this once the pinned AITER has it).