Skip to content

vllm.v1.attention.ops.ultraquant.triton_store

Triton store kernel for the ultraquant KV cache format.

Per-token, per-head, per-group-of-32 the kernel computes:

s_raw = c * absmax(group)            # c = 0.156 by default
s     = 2^round(log2(s_raw))         # UE8M0 snap (power of 2)
code  = quantize_to_fp4(group / s)   # OCP E2M1, 4 bits/elt

and stores code as packed nibbles + s as a single UE8M0 byte per group. The output layout matches format.py (272 B/slot for D=256).

K is Hadamard-rotated in-register; V is not. There is no per-token L2 norm. The UE8M0 snap makes s a power of two so scaled F8F6F4 MFMA can consume it on the read side.

Functions:

  • ultraquant_store –

    Launch the ultraquant store kernel. Writes K/V into kv_cache

_kv_cache_flat(kv_cache)

1-D uint8 view of the raw KV allocation (handles padded layouts).

ultraquant_store(key, value, kv_cache, slot_mapping, *, PiT=None, constant_c=None)

Launch the ultraquant store kernel. Writes K/V into kv_cache in-place at the slots specified by slot_mapping.