vllm.models.deepseek_v41.amd.akr_mhc
¶
DeepSeek-V4.1 mHC routes on amd_kernels (hidden 5120, 4 streams).
mhc_seam: post-mix of the previous sublayer + pre-mix, Sinkhorn and RMSNorm of the next one, in place of the AITER mega-mHC seam. It also emits the layer input as MXFP8 wherever a consumer reads those codes (the attention's fused wq_a + wkv, the fused EP8 experts, the shared expert's gate_up), so no quantize launch sits between the seam and those GEMMs; on request also the mean of the new streams (the DSpark auxiliary hidden state).mhc_tail: post-mix, collapse and final RMSNorm after the last layer.mhc_wo_b: wo_b GEMM with the attention post-mix as its epilogue, then the FFN seam's gate finisher.mhc_ffn: shared-expert down GEMM plus the routed output with the FFN post-mix as its epilogue, then the next layer's attention seam.
Each decision is on the static row count, so a captured shape takes one branch in every layer. The seam, the fused epilogues and the finisher share per-device scratch: they run serially on one stream (the stock aux-stream gate overlap is off where the seam serves).
Classes:
-
AkrMhc–DeepseekV4DecoderLayer.akr_mhc: packed gate weights, the seam and the -
SeamCarry–What a layer whose FFN epilogue chain already ran the next attention
Functions:
-
attach_codes–Hand the seam's MXFP8 copy of
xto the stock linears that read it. -
attached_codes–The MXFP8 copy of
xthat AITER's MXFP8 mHC seam attached (where that -
defer_aux–Whether the auxiliary hidden state after layer
nxt - 1comes from the -
model_tail–The end of
DeepseekV4Model.forwardon the last PP rank: post-mix,
AkrMhc
¶
DeepseekV4DecoderLayer.akr_mhc: packed gate weights, the seam and the
fused chains of one decoder layer.
Methods:
-
attn_wants_codes–Whether the attention seam emits the layer input as MXFP8: wherever
-
ffn_chain–Shared down + routed add with the FFN post-mix as the epilogue, then
-
post_load_chains–The fused epilogues read the stock linears' preshuffled weights.
-
pre–Drop-in for
MHCPreDelayedOp.__call__that falls back tostock. -
quant_output–The last seam's MXFP8 output, if it was asked for.
-
wo_b_chain–wo_b with the attention post-mix as its epilogue, then the FFN seam:
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
attn_wants_codes(m)
¶
Whether the attention seam emits the layer input as MXFP8: wherever it runs and the stock fused wq_a + wkv linear reads codes (seam with the MXFP8 epilogue + the stock GEMM on its codes beat the bf16 seam + the dense_gemm entry by 0.5-2.3 us at the seam's row counts).
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
ffn_chain(nxt, shared_act, routed, residual, post_mix, res_mix, ffn_pre, *, aux)
¶
Shared down + routed add with the FFN post-mix as the epilogue, then the next layer's attention seam: (residual, post, comb, SeamCarry).
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
post_load_chains()
¶
The fused epilogues read the stock linears' preshuffled weights.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
pre(stock, residual, fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, pre_mix=None, x=None, norm_weight=None, norm_eps=1e-06, sublayer_out=None, post_layer_mix=None, comb_res_mix=None, fn_packed=None)
¶
Drop-in for MHCPreDelayedOp.__call__ that falls back to stock.
want_quant / want_aux ask for the extra outputs, read back from
last_quant / last_aux.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
quant_output(dtype)
¶
The last seam's MXFP8 output, if it was asked for.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
wo_b_chain(z, residual, post_mix, res_mix, attn_pre, *, quant, dtype)
¶
wo_b with the attention post-mix as its epilogue, then the FFN seam: (residual, post, comb, layer_input, ffn_pre, MXFP8 input or None).
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
SeamCarry
¶
Bases: NamedTuple
What a layer whose FFN epilogue chain already ran the next attention seam returns in place of its FFN output: the next layer's normed input, its attention pre-mix and, before an auxiliary layer, the stream mean. The accompanying residual is already post-mixed.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
attach_codes(x, codes)
¶
Hand the seam's MXFP8 copy of x to the stock linears that read it.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
attached_codes(x)
¶
The MXFP8 copy of x that AITER's MXFP8 mHC seam attached (where that
seam ran), with byte scales as the amd_kernels entries read them.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
defer_aux(model, nxt, layer_ids, m)
¶
Whether the auxiliary hidden state after layer nxt - 1 comes from the
seam of layer nxt (or, for the last layer, from the model tail) instead
of a stock post-mix + mean.
Source code in vllm/models/deepseek_v41/amd/akr_mhc.py
model_tail(model, x, residual, post_mix, res_mix, pre_mix, aux_hidden_states, final_aux)
¶
The end of DeepseekV4Model.forward on the last PP rank: post-mix,
the DSpark hidden-buffer copy, collapse and final norm (and the stream
mean of the last auxiliary layer if _run_layers deferred it).