Skip to content

vllm.model_executor.layers.hpc.gated_mla

Enablement gate for the HPC fused gated-MLA GEMM.

hpc.gated_mla_gemm fuses the MLA output gating -- the gate projection, the sigmoid and the elementwise product -- into a single kernel launch, replacing the eager attn_out * sigmoid(hidden_states @ weight.T) sequence.

Kernel constraints
  • Requires VLLM_ENABLE_HPC_OPS=1
  • Requires the hpc package (.so) built for the current arch
  • Only sm100 / sm103 (compute capability 100, 103)
  • All three operands must be bfloat16 and contiguous
  • The gate width must be a multiple of 256
  • Only elementwise gating (headwise has no fused form)

Functions:

hpc_gated_mla_gemm(x, weight, atten_output)

Fused atten_output * sigmoid(x @ weight.T).

Parameters:

  • x

    (Tensor) –

    [m, k] bfloat16, contiguous.

  • weight

    (Tensor) –

    [n, k] bfloat16, contiguous and row-major (the kernel transposes it). n must be a multiple of 256.

  • atten_output

    (Tensor) –

    [m, n] bfloat16, contiguous.

Returns:

hpc_gated_mla_supported(gating_type, attn_output_gate)

Gate for running the MLA output gating through hpc.gated_mla_gemm.