Skip to content

vllm.model_executor.kernels.linear.mxfp8.rocm_native

Native MXFP8 linear GEMM for AMD CDNA4 (gfx950) via Triton tl.dot_scaled.

Consumes the FP8 E4M3 weights + E8M0 block scales directly (no dequant-to-BF16); activations are MXFP8-quantized per token (inside the GEMM for small M), or arrive pre-quantized as a QuantizedActivation with row-major (not swizzled) E8M0 scales. Uses the CDNA4 hardware microscaling matrix cores. dot_scaled tiles K by 128; a weight whose K is not a multiple of that is dequantized to BF16 once at load and served by a plain linear instead, since can_implement does not filter on K.

Weights with 32x32 scale blocks (DeepSeek V4.1) run a block-scaled Triton GEMM, or AITER's tuned FlyDSL GEMMs on gfx950, on a weight preshuffled at load.

Classes:

RocmDotScaledMxfp8LinearKernel

Bases: Mxfp8LinearKernel

Native CDNA4 (gfx950) MXFP8 linear via Triton tl.dot_scaled.

Methods:

_flydsl_fallback(layer) staticmethod

Why a 32x32 block-scaled layer cannot run AITER's tuned FlyDSL GEMMs (batched wo_a as [G, N / G, K]), or None if it can.

supports_quantized_input(layer) staticmethod

Whether apply_weights reads a QuantizedActivation for layer as is (fp8 weights), rather than dequantizing it back.

_as_block32_scale(weight_scale)

The [N / 32, K / 32] block scales, if every 32 rows share their scales.

_launch(x, x_scale, w, w_scale, out, block_m, block_n, block_k, num_warps, num_stages)

out = x @ w.T. x_scale None means x is the unquantized activation and is MXFP8-quantized inside the kernel.

_quant_mxfp8_tile(x, FP8_MAX, TINY)

MXFP8-quantize a [BLOCK_M, BLOCK_K] tile: bit-exact with mxfp8_e4m3_quantize (see _mxfp8_quant_triton_kernel for why the scale is applied as a reciprocal).

_select_cfg(M, N, K)

(BLOCK_M, BLOCK_N, BLOCK_K, num_warps, num_stages) — graph-tuned on gfx950.

The M-bucketed, shape-adaptive tile selection here is the speedup over the upstream 2-bucket launcher. Tiles are pipelined (num_stages>=2, larger BLOCK_K) and occupancy- and shape-aware: keyed on the LOCAL (M, N, K), so it adapts to the TP-sharded shapes (e.g. MiniMax-M3 TP=4 vs TP=8, where local N and K differ) — large-K prefill uses BLOCK_K=256; short-K (K=768) widens N. BLOCK_K must divide K (the K-loop is unmasked), so every BLOCK_K below is guarded to be K-divisible (served K: 384/768/1024/2048/6144).

_select_fused_quant_cfg(M, N, K)

Tile config with the activation quant fused (M <= 16), or None to quantize separately.

_wide_prefill_tile_pays(M, N)

Whether the 256x256x128 large-prefill tile beats the 128x128 one.