flashinfer.fused_moe.QuantConfig¶
- class flashinfer.fused_moe.QuantConfig(weight: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, activation: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, output: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, *, swizzled_scale_factors: bool | None = None, per_token_scale: bool | None = None, nvfp4_4over6: ~flashinfer.quantization.nvfp4_quantization_utils.NVFP44Over6Config | None = <nvfp4_4over6 unset: read FLASHINFER_NVFP4_4OVER6*>)¶
Quantization scheme: MMA weight/activation formats plus the result format.
QuantConfigonly checks that each axis is aQuantFormat. Legal combinations are runner capabilities (supported_quant_variantsandsupported_output_formats), not an allow-list in this dataclass.- Parameters:
weight (QuantFormat) – MMA weight and activation formats. An omitted axis is BF16, i.e. unquantized:
QuantConfig()is BF16×BF16 andQuantConfig(weight=MXFP4)is MXFP4 weights with BF16 activations (W4A16). MXFP4×MXFP8 must be spelled with both axes.activation (QuantFormat) – MMA weight and activation formats. An omitted axis is BF16, i.e. unquantized:
QuantConfig()is BF16×BF16 andQuantConfig(weight=MXFP4)is MXFP4 weights with BF16 activations (W4A16). MXFP4×MXFP8 must be spelled with both axes.output (QuantFormat) – Layer output format. Default BF16. Pass
QuantFormat.FP16, nottorch.float16.swizzled_scale_factors (bool or None) – Whether block scale factors use the swizzled (vs linear) layout.
None→ backend default. Mirrors core’sswizzled_input_sf. FinerSfLayout(128x4 / 8x4 / linear) selection is deferred (design doc C42): unlikeRoutingMethodType/ActivationType,SfLayouthas no eval-safe__repr__, so exposing it here would break theeval(repr(cfg))round-trip — a bool keeps this config serializable.per_token_scale (bool or None) – Whether activations carry a per-token scale (vs per-tensor / block).
None→ backend default.nvfp4_4over6 (NVFP44Over6Config or None) –
NVFP4 “4over6” scale-candidate search for the activation quantization the kernels perform at runtime. Weights are quantized by the caller ahead of the call and are not affected.
unset (the default): read the legacy
FLASHINFER_NVFP4_4OVER6*environment variables on every call (byte-for-byte the old behaviour).None: 4over6 off. The environment is ignored.NVFP44Over6Config(...): on with exactly that recipe. The environment is ignored, with no per-field merge.
Only NVFP4 activations accept an explicit value (
__post_init__raises otherwise). A runner that has not threaded the setting into its quantizer rejects an explicit value instead of dropping it; seeMoERunner.supports_nvfp4_4over6. A pinned recipe also pins the GEMM2-input scale of the weight pack: build it withCuteDslConfig.prepare_weights(..., nvfp4_4over6=<the same value>)or the call raisesValueError. An unset field is not emitted by__repr__, so theeval(repr(cfg))round-trip still holds.
- Raises:
ValueError – If
nvfp4_4over6is set (toNoneor a config) whenactivationis notQuantFormat.NVFP4.TypeError – If
nvfp4_4over6is neitherNonenor anNVFP44Over6Config.
- __init__(weight: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, activation: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, output: ~flashinfer.fused_moe.api.QuantFormat = QuantFormat.BF16, *, swizzled_scale_factors: bool | None = None, per_token_scale: bool | None = None, nvfp4_4over6: ~flashinfer.quantization.nvfp4_quantization_utils.NVFP44Over6Config | None = <nvfp4_4over6 unset: read FLASHINFER_NVFP4_4OVER6*>) None¶
Methods
__init__([weight, activation, output, ...])Attributes
activationnvfp4_4over6outputpairMMA
(weight, activation)pair used for runner matching.per_token_scaleswizzled_scale_factorsweight