The implementation plugs into SGLang's paged KV Cache and splits into three paths by phase. In the initial prefill phase, attention computes directly with BF16 Q × FP8 K/V while quantizing KV from FP8 into NVFP4 and writing it to the persistent cache; this phase does not read the cache, so there is no dequantization overhead.
In the chunked prefill/extend phase, the cached prefix is gathered out and dequantized into a cross-layer shared FP8 workspace, concatenated with the current chunk's KV for FP8 attention, and after computation the current chunk is quantized into the NVFP4 cache; the shared workspace exists to control extra VRAM overhead.
Decode is the most critical part. Decode is memory-bound, and dequantizing before computing would add a full extra VRAM round trip, so the kernel reads NVFP4 directly and dequantizes on the fly internally: packed K/V tiles and E4M3 block scales go into shared memory, the cvt.rn.bf16x2.e2m1x2 instruction converts pairs in registers, the global scale is passed in through the BMM scaling parameter, and computation is BF16 throughout.
The trade-off of this design can be summarized as: prefill is compute-bound, so it can tolerate one extra quantized write; decode is memory-bound, so it must read exactly as much as it computes.