vllm.model_executor.layers.mhc
¶
Classes:
-
HCHeadOp–HC head reduction for DeepSeek V4.
-
MHCFusedPostPreOp–Fused MHC post block followed by the next MHC pre block.
-
MHCPostOp–MHC post block.
-
MHCPreDelayedOp–MHC pre block using the pre-mix carried from the previous sublayer.
-
MHCPreOp–MHC pre block.
Functions:
-
hc_contract–[s, n * hidden_size] -> [s, hidden_size] by averaging.
-
hc_expand–[s, hidden_size] -> [s, n * hidden_size] by replication.
HCHeadOp
¶
Bases: CustomOp
HC head reduction for DeepSeek V4.
Computes gates from the RMS-normalized flattened HC residual and returns out = sum_i gate_i * residual_i, collapsing hc_mult streams to one.
MHCFusedPostPreOp
¶
Bases: CustomOp
Fused MHC post block followed by the next MHC pre block.
Equivalent to applying MHCPostOp and then MHCPreOp to the updated residual streams, returning residual_cur, post_mix_cur, comb_mix_cur, and layer_input_cur.
MHCPostOp
¶
Bases: CustomOp
MHC post block.
Combines the layer output with the HC residual streams: out_j = post_layer_mix_j * x + sum_i comb_res_mix_ij * residual_i.
MHCPreDelayedOp
¶
Bases: CustomOp
MHC pre block using the pre-mix carried from the previous sublayer.
Same gates as MHCPreOp, but the stream collapse applies the
caller's pre_mix and this sublayer's pre-mix is returned for the next
sublayer seam.
Passing sublayer_out / post_layer_mix / comb_res_mix also
applies the preceding post block, which lets AITER fold it into the pre
projection and saves a launch. Returns residual, post_mix, comb_mix,
layer_input, next_pre_mix; residual is the caller's own tensor when
no post is requested. fn_packed, fn packed by
rocm_aiter_ops.mega_mhc_pack_fn, runs the fused ROCm seam as one
Mega-MHC launch; other paths ignore it.
MHCPreOp
¶
Bases: CustomOp
MHC pre block.
Computes mix logits from RMS-normalized HC residual streams, then returns post_mix, comb_mix, and layer_input = sum_i pre_mix_i * residual_i.
hc_contract(x, n)
¶
[s, n * hidden_size] -> [s, hidden_size] by averaging.
hc_expand(x, n)
¶
[s, hidden_size] -> [s, n * hidden_size] by replication.