Compare commits

...
Author SHA1 Message Date
samsjaandGitHub 3925d27f4f feat(inference): allow MXFP8 online quantization (#4045)
## What

`[inference.vllm] quantization` is typed as `Literal["fp8_per_block"]`,
so it is currently impossible to serve with MXFP8. This PR adds
`"mxfp8"`.

## Why

vLLM supports `--quantization mxfp8` as an online shorthand: a BF16/FP16
checkpoint's weights are quantized to MXFP8 at load (E4M3 values with
block-32 E8M0 scales) and activations are quantized dynamically per
forward, for both dense linears and MoE experts. On Blackwell
(SM100/SM103) vLLM auto-selects native W8A8 block-scaled GEMMs
(FlashInfer CuTe-DSL); older GPUs fall back to W8A16 (Marlin). This is
useful for serving BF16 SFT exports on B200/B300 without building an FP8
checkpoint.

## How

The value already passes through verbatim to vLLM's `--quantization`;
the pydantic `Literal` was the only gate. vLLM validates the shorthand
and picks the kernel at startup (`Using <kernel> for MXFP8 GEMM`), so no
further wiring is needed. Unknown shorthands (e.g. `mxfp4`) stay
rejected.

Verified locally: `InferenceConfig(vllm={"quantization": "mxfp8"})`
validates, `ruff check`/`format` pass, and `tests/unit/test_configs.py`
shows no new failures (20 pre-existing failures reproduce on pristine
`origin/main` with this checkout's venv).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Single-type widening in config validation with no runtime wiring
changes; vLLM still validates quantization at server startup.
> 
> **Overview**
> Extends **`inference.vllm.quantization`** so configs can set
**`mxfp8`** alongside the existing **`fp8_per_block`** option. That
value already forwards to vLLM’s `--quantization`; the only change is
lifting the Pydantic **`Literal`** gate that previously rejected MXFP8
at parse time.
> 
> This enables online MXFP8 serving (quantize BF16/FP16 weights at load,
dynamic activation quant) on supported hardware without a separate FP8
checkpoint—useful for BF16 SFT exports on Blackwell-class GPUs.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
777ad501a85ced1985b1b735b4d633ff2ec2d71d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-10-13 17:48:24 -07:00
@@ -29,7 +29,7 @@ class ServerConfig(BaseConfig):
# not depend on vLLM, and importing it costs seconds in every config-parsing process.
VALID_VLLM_LORA_RANKS = (8, 16, 32, 64, 128, 256, 320, 512)
QuantizationType = Literal["fp8_per_block"]
QuantizationType = Literal["fp8_per_block", "mxfp8"]
class VllmConfig(BaseConfig):