Module kv_dequant

Module kv_dequant 

Source
Expand description

Host-side dequantization of paged KV cache blocks → BF16.

Used by --high-speed-swap Phase 6.2.c to produce BF16 source data for the orchestrator’s tile-streaming attention kernel from any of Atlas’s quantized KV layouts. The kernel-side packing/scale layouts mirrored here:

Quantdata bytes/elemscaleLUTsource kernel
BF162noneidentity(direct copy, not in this module)
FP81 (E4M3)tensore4m3_lutreshape_and_cache_fp8.cu
NVFP40.5 (4-bit)groupNVFP4_E2M1_LUTpaged_decode_attn_nvfp4.cu
Turbo40.5 (4-bit)groupTURBO4_LUT (Lloyd-Max 16)paged_decode_attn_turbo4.cu
Turbo30.375 (3-bit)groupTURBO3_LUT (Lloyd-Max 8)paged_decode_attn_turbo3.cu
Turbo81 (E4M3)groupe4m3_lutpaged_decode_attn_turbo8.cu

“Group” scales cover 16 elements per scale byte (NVFP4_GROUP_SIZE) and are stored in a separate section after the data section within each block. All LUTs match their CUDA-side counterparts byte-for-byte.

Constants§

NVFP4_E2M1_LUT
E2M1 4-bit codebook (NVFP4). Matches kernels/gb10/common/paged_decode_attn_nvfp4.cu:118.
NVFP4_GROUP_SIZE
Group size for per-group FP8 scales. Matches NVFP4_GROUP_SIZE in the per-quant attention kernels.
TURBO3_LUT
Turbo3 8-level Lloyd-Max codebook. Matches kernels/gb10/common/paged_decode_attn_turbo3.cu:137.
TURBO4_LUT
Turbo4 16-level Lloyd-Max codebook. Matches kernels/gb10/common/paged_decode_attn_turbo4.cu:121.

Functions§

dequant_4bit_block_to_bf16
Dequant a 4-bit packed (NVFP4 or Turbo4) KV block to BF16.
dequant_fp8_to_bf16
Dequant FP8 (E4M3) bytes to BF16, applying a per-tensor scale.
dequant_turbo3_block_to_bf16
Dequant a Turbo3 (3-bit packed) KV block to BF16.
dequant_turbo8_block_to_bf16
Dequant a Turbo8 (FP8 E4M3 data + per-group BF16 scales) KV block to BF16.
e4m3_lut
Borrow the compile-time table.