vllm.models.flint.ops.linear
¶
Flint dense linears with a small-M CuTe GEMV fast path.
NVFP4 (W4A16): the GEMV (nvfp4_gemv) reads the very tensors the FlashInfer
CuTe-DSL kernel was prepared with (ModelOpt-packed weight, 128x4-swizzled
scales), so dispatching per token count costs no extra weight memory; larger
M stays on FlashInfer. BF16: the same GEMV kernel on BF16 weights where it
beats cuBLAS, cuBLAS otherwise.
Classes:
-
FlintBf16LinearMethod–BF16 linear: CuTe GEMV for small M, cuBLAS otherwise.
-
FlintNvFp4LinearKernel–FlashInfer CuTe-DSL W4A16 GEMM with a small-M CuTe GEMV fast path.
Functions:
-
check_merged_global_scales–Pass checkpoint tensors through, raising if the NVFP4 global scales of
-
gate_up_silu_mul–silu_and_mul(layer(x))in one GEMV for small M, else None. -
install_flint_dense_kernels–Route the dense linears of
modelthrough the Flint GEMV (launched
FlintBf16LinearMethod
¶
Bases: UnquantizedLinearMethod
BF16 linear: CuTe GEMV for small M, cuBLAS otherwise.
Source code in vllm/models/flint/ops/linear.py
FlintNvFp4LinearKernel
¶
Bases: FlashInferCuteDslNvFp4W4A16LinearKernel
FlashInfer CuTe-DSL W4A16 GEMM with a small-M CuTe GEMV fast path.
Source code in vllm/models/flint/ops/linear.py
_dequant_gemm(layer, x)
¶
bf16(fp32(x @ bf16(e2m1 * e4m3).T) * global) via cuBLAS: the global
scale is the GEMM alpha, applied to the FP32 accumulator.
Source code in vllm/models/flint/ops/linear.py
_setup_gemv(layer, n, k, pdl, bf16)
¶
Enable (and compile) the GEMV where its tuned table lists the shape.
Source code in vllm/models/flint/ops/linear.py
_swizzled_scale_buffer(weight_scale, n, k)
¶
The flat 128x4-swizzled scale buffer behind FlashInfer's strided view of it (no copy).
Source code in vllm/models/flint/ops/linear.py
_use_gemv(layer, x, silu_mul)
¶
Whether the tuned dispatch table picks the GEMV for this M.
Source code in vllm/models/flint/ops/linear.py
check_merged_global_scales(weights)
¶
Pass checkpoint tensors through, raising if the NVFP4 global scales of shards fused into one linear (q/k/v, gate/up) differ: the fused layer keeps a single global scale.
Source code in vllm/models/flint/ops/linear.py
gate_up_silu_mul(layer, x)
¶
silu_and_mul(layer(x)) in one GEMV for small M, else None.
Source code in vllm/models/flint/ops/linear.py
install_flint_dense_kernels(model)
¶
Route the dense linears of model through the Flint GEMV (launched
with PDL except the BF16 _BF16_NO_PDL_SUFFIXES): NVFP4 linears get
FlintNvFp4LinearKernel, unquantized BF16 projections
(_DENSE_SUFFIXES) FlintBf16LinearMethod. Must run before weights
are processed after loading.