DeepSeek-V4.1 cache format and graph execution#
V4.1 reuses ATOM’s V4 attention, MoE and graph execution infrastructure. Model arithmetic, cache representation and execution policy have separate owners. See the runtime guide for configuration admission and the model recipe for launch commands.
Request metadata#
Request metadata reuses V4’s persistent CpuGpuBuffer storage, token-layout
helpers and state-slot publisher. V4.1 consumes v4_meta_state_slot_out.
Pool-slot conversion belongs to the cache geometry.
Actual request and token counts are scheduled_bs / scheduled_tokens;
execution capacities are running_bs / running_tokens. Block-table stride
and buffer addresses remain fixed across steps. Padding tokens carry V4’s
-1 request-ID sentinel; padding requests have zero query length.
Cache format and attention boundary#
The main pool accepts kv_cache_dtype="fp8" (the deployed configuration),
"bf16" or "fp4". The index plane is independent: index_cache_dtype="fp8"
(default) or "fp4".
Region |
FP8 main-pool configuration |
BF16 main-pool configuration |
FP4 main-pool configuration |
|---|---|---|---|
Main KV, 512 dimensions |
MXFP8: separate E4M3 data and E8M0 scale planes, group 32 (512 + 16 B per logical row) |
BF16 |
Separate E2M1 FP4 data and E4M3 scale planes, group 16 (256 + 32 B per logical row) |
SWA, 512 dimensions |
Same MXFP8 planes |
BF16 |
Separate E4M3 data and E8M0 scale planes, group 32 |
Index keys, 128 dimensions |
Per |
E4M3 FP8 with a per-key power-of-two scale |
Same FP8 index format |
Each quantized CSA source and each layer’s SWA source exposes contiguous data and scale planes. The 528 B MXFP8 cost is a logical row’s total across those planes, not an interleaved physical row stride. CSA and SWA have independent row spaces; prefill stages the batch’s rings followed by current KV in the SWA source, while decode reads the persistent ring directly.
The FP8 pool holds 1.84x the rows of the BF16 one. Its sources use int32 row
indices, and attention reads the data and scale planes as they are stored:
the query is quantized to the same MXFP8 format, and AITER’s
mla_sparse_prefill_v41 (fp8_attention.sparse_attn_v41_paged_2src) attends
over the pool and the window, prefill and decode alike.
The index writer stores scales as FP32 in preshuffled tiles. Global owner
regions share block IDs while keeping separate index planes. FP32 compressor
tails and committed Engram histories retain their precision and checkpoint
semantics. V41PoolGeometry declares allocation sizes, alignment and image
layout identity; memory planning and checkpoint copies use those declarations.
For FP4 KV, ATOM_DSV41_A8W4_ATTN=auto (the default) asks AITER whether
the live query can use A8W4 over NVFP4 CSA and MXFP8 SWA planes. On supported
gfx950 configurations this is the native path. off, or an ineligible
query/backend, uses the BF16 adapter. AITER’s public V4.1 capability API is
required by this revision.
On that adapter, packed_rows.py decodes selected plane rows, and
packed_attention.py uses bounded BF16 scratch and
passes ordinary int32 row indices to V4 attention. Prefill keeps the current
chunk in BF16; decode preserves V4’s batch size and split-K dispatch. Neither
path materializes the entire historical main KV pool.
On the BF16 pool (and on the FP8 pool through its MXFP8 twin above), decode
attention reads two sources (sparse_attn_v4_paged_2src): the selection from
the pool, and the window
through the layer’s own ring (ring_view), whose rows are one list shared by
every layer. An index group’s layers share one selection plane. The OPUS kernel
splits each token’s keys across blocks when the step has too few tokens to
fill the GPU.
A compressed main row is written by the compressor’s own kernel
(fused_compress_attn) in the pool’s row format: BF16, or on the FP8 / FP4
pools (quant_mode “planar_fp8” / “planar_fp4”) the row rounded to BF16 and
quantized by quantize_fp8 / quantize_fp4’s rule into separate data and
scale planes. The
kernel resolves each plan row’s PAGE through the block table; padding rows are
skipped on the device, including during graph replay.
Graph ownership#
Use CompilationConfig(level=0, cudagraph_mode=CUDAGraphMode.FULL) with
enforce_eager=False for whole-forward decode capture. The existing runner
owns one target graph per (batch size, query bucket). Non-speculative decode
replays one target graph; DSpark additionally replays its request-count-keyed
draft graph. Prefill and host Engram lookup stay outside these graphs.
Capture and replay use the forward’s declared execution capacity. Compression
plans have fixed capacity and sentinel-filled tails. Host cursor publication
occurs during input preparation, since replay does not execute Python.
BatchStep.begin_forward clears derived per-forward tensors before capture.
Startup capture uses the serving allocation and block 0 for synthetic
requests. The runtime validator checks that capture preserves live cache pages.
TR_HYBRID is also accepted by the runtime; development and validation use
level 0, and broader compiler support remains outside the supported scope.
Memory and numerical limits#
The FP4 index plane packs the scorer’s FP32 logits: each row as long as its own visibility, aligned, in one buffer sized from the PAGE pool the memory budget can hold rather than from the model length. A step whose rows overflow that buffer – requests sharing a prefix the pool stores once – runs eagerly, scored in bands, instead of from a decode graph. The FP8 plane keeps a plane band at the int32 addressing limit, which can require nearly 8 GiB, plus its tile tables; reserve scratch headroom for it when sizing long-context workloads. Quantized queries and selection workspace occupy memory beside either.
A Reindex layer scores candidate_topk_blocks blocks rather than the whole
context: the index plane is paged at candidate_block_size, so the candidate
source’s list is the scorer’s block table. Compaction clamps the last kept
block’s visible span to one block, so its context stays within the actual
kept count even if selection omits the newest block. Candidate ranking still
pins the newest block independently.
Cache packing and expert activation quantization affect numerical behavior. Native FP8/FP4 execution does not promise bitwise equality with an all-BF16 implementation or the mathematical reference. Validate quality for the chosen cache format, batch shape and workload. Image quality limitations are described in the vision guide; speculative execution has separate constraints.
For throughput and latency, use the standard benchmark in the serving guide with matched request lengths, concurrency, cache configuration and graph mode. Include warmup and repeated, alternating runs. Cache capacity savings and isolated kernel timings do not establish end-to-end serving speedups.