Executive Takeaway
The biggest non-prefill/refill opportunities for this stack are not “replace attention with FA3.” The repo is already in the right family: SGLang + FlashInfer + ModelOpt FP4/NVFP4 + hybrid Marlin/CUTLASS. The next useful work should be:
- Better FP4 GEMM backend selection by actual production shapes.
- Fusing activation/norm/quantization around MLP and GLA paths.
- Testing TRT-LLM/FlashInfer FP4 layouts where they avoid extra shuffle/scale overhead.
- Treating KV4/NVFP4 KV as accuracy-risky but potentially high payoff for long-context decode.
- Keeping Marlin for small
M only, but retuning with CUDA graph + actual EAGLE mixed batch shapes.
Relevant Upstream Findings
FlashAttention-3 is mainly a Hopper attention kernel story: warp specialization, TMA overlap, interleaved matmul/softmax, FP8 attention, with reported 1.5-2.0x H100 attention speedups and up to 740 TFLOP/s FP16 / near 1.2 PFLOP/s FP8 in the paper. It is valuable as a design reference, but less directly actionable than FlashInfer for our current paged sparse MiniCPM backend. Source: FlashAttention-3 arXiv.
FlashInfer is more relevant to this repo. The paper explicitly targets serving heterogeneity, block-sparse KV formats, CUDAGraph compatibility, and reports 29-69% inter-token latency reduction vs compiler backends, 28-30% long-context latency reduction, and 13-17% parallel generation speedup. Source: FlashInfer arXiv. The docs also expose exactly the knobs we care about: mm_fp4, nvfp4_quantize, fused_add_rmsnorm_quant, silu_and_mul_scaled_nvfp4_experts_quantize, top-k transforms, and paged attention APIs. Source: FlashInfer GEMM docs.
Blackwell FP4 is real hardware opportunity, but layout-sensitive. CUTLASS documents block-scaled tcgen05.mma FP4/NVFP4 paths, scale-factor vector sizes 16/32, 1SM/2SM dispatch policies, and epilogue fusion support for producing FP4/NVFP4 outputs plus block scale factors. Source: CUTLASS Blackwell GEMMs.
FlashInfer mm_fp4 already supports cudnn, trtllm, cutlass, cute-dsl, b12x, and auto; on SM120, auto prefers b12x, then cutlass, then cudnn. It also states TRT-LLM backend needs different B scale-factor shuffling, while CUTLASS/cuDNN use unshuffled 128x4 scale layout. Source: FlashInfer mm_fp4. This directly matches our SGLANG_FLASHINFER_FP4_GEMM_BACKEND, SGLANG_FP4_TUNE_CACHE, and modelopt FP4 path.
NVFP4 is likely the right low-bit format to stay with. NVIDIA’s NVFP4 writeup says it uses E2M1 values, one FP8 E4M3 scale per 16-value block, plus a tensor-level FP32 scale; it claims about 3.5x model memory reduction vs FP16 and 1.8x vs FP8, with <=1% degradation in their DeepSeek-R1-0528 comparison. Source: NVIDIA NVFP4 blog. TensorRT-LLM docs confirm ModelOpt prequantized checkpoints, FP4/FP8 recipes, and Blackwell support matrices. Source: TensorRT-LLM quantization.
Marlin remains relevant for decode. The MARLIN paper’s key result is that W4 mixed-precision kernels can retain near-maximum 4x quantization speedup up to batch sizes 16-32, and still help at 64-128, with up to 2.8x end-to-end speedup in vLLM. Source: MARLIN arXiv. That supports the current hybrid SGLANG_MARLIN_DECODE_THRESHOLD=48, but only if retuned under the production graph/spec path.
QServe is useful mostly as a design warning: W4A8KV4 can win, but the paper says dequant overhead can be 20-90% if done naively, so the gain comes from progressive quantization, compute-aware reorder, register-level dequant, and making attention memory-bound with KV4. Source: QServe arXiv.
QuaRot/SmoothQuant are accuracy tools, not immediate kernel wins. QuaRot rotates hidden state, FFN activations, attention, and KV cache to enable end-to-end 4-bit inference with retained zero-shot performance on LLaMA2-70B. Source: QuaRot arXiv. SmoothQuant migrates activation outlier difficulty into weights to enable W8A8 and reports up to 1.56x speedup. Source: SmoothQuant arXiv. For us, these matter if NVFP4 activation/KV accuracy is the blocker.
Fit To Current Stack
Your current path already has the most promising primitives:
modelopt_fp4 target weights with FourOverSix/GPTQ/NVFP4.
- FlashInfer FP4 GEMM import path and backend env selection.
- Hybrid Marlin/CUTLASS dispatch with per-shape threshold scaffolding.
- Dispatch histogram tooling for
(out, in, M, backend).
- MiniCPM FlashInfer backend with plan cache and direct top-k to FlashInfer metadata paths.
- GLA direct decode and fused recurrent kernels with intermediate state export.
So I would avoid large framework swaps first. The risk-adjusted work is targeted backend/layout/fusion experiments.
Concrete Experiments
-
Production FP4 GEMM backend sweep
Use existing dispatch histogram and run the same public-eval workload with:
SGLANG_FLASHINFER_FP4_GEMM_BACKEND=auto|cutlass|cudnn|trtllm|b12x
and fixed SGLANG_MARLIN_DECODE_THRESHOLD=0,32,48,64,96.
Record ori_accuracy, tok/s, p50/p99 decode, and kernel trace buckets. TRT-LLM backend is only valid if weight/scale layout matches its shuffle requirement.
-
Retune Marlin threshold per shape under real CUDA graph
The existing comments already say earlier thresholds were artifacts under non-production config. Redo per shape:
(32768,4096) gate_up, (4096,16384) down, (4608,4096) qkv, (4096,4096) o, (12288,4096) gla_qkv, (4096,12288) eagle_fc.
Success condition: speedup on bench/mini_bench.sh and no public accuracy loss.
-
FP4 epilogue fusion for MLP
Investigate replacing gate_up GEMM -> silu/mul -> quantize -> down GEMM with a fused SiLU/mul/NVFP4 quant stage before down projection. FlashInfer already exposes silu_and_mul_scaled_nvfp4_experts_quantize; CUTLASS documents epilogue fusion to produce FP4 plus scale factors. This targets MLP bandwidth and launch overhead.
-
RMSNorm + quant fusion
Where the next op consumes FP4/FP8 activation, benchmark FlashInfer fused_add_rmsnorm_quant against current norm + activation quant. This is low-risk if isolated behind an env flag, and it directly removes a launch and one read/write of hidden states.
-
GLA decode kernel profiling before more attention work
Enable the MiniCPM/GLA profile buckets and quantify gla_direct_decode_bk64_2k, recurrent kernel, initial state copy, temporal write, and torch sum/cast. If GLA dominates decode, FA3/attention work will not move total latency much.
-
NVFP4 KV cache trial as experimental branch
TensorRT-LLM supports NVFP4 KV through ModelOpt, but currently notes constraints around offline quantization and FP8 weight/activation when NVFP4 KV is enabled. For SGLang, test kv-cache-dtype fp4_e2m1 only as a guarded accuracy experiment. Run no-spec/spec answer consistency on long-context cases; do not judge only tok/s.
-
Scale-factor layout audit
Confirm every FP4 path uses the expected layout: CUTLASS/cuDNN unshuffled 128x4, TRT-LLM B shuffled, NVFP4 block size 16. A wrong layout can appear as either garbage output or silent performance loss.
-
It may help if NVFP4 W4A4 accuracy or activation quant overhead is bad. But implementing W4A8KV4 would compete with the current ModelOpt FP4 path and require new kernels/reorder. I’d only pursue it after proving FP4 activation quantization is the bottleneck.
Priority Order
Do first: FP4 backend sweep, Marlin threshold retune, GLA/MLP profile split.
Do next: fused MLP activation+quant, fused norm+quant, scale layout fixes.
Do only if accuracy budget allows: FP4/NVFP4 KV, QuaRot-style rotations, SmoothQuant-style activation smoothing.
I did not edit files.