Repository navigation
feat(pytorch): add last-only prefill checkpoint saving for hybrid attention - #5049
Conversation
| alignment = seq._seq_meta.prefill_save_alignment | ||
| if not alignment: | ||
| return None | ||
| input_shift = max(seq.prefill_input_shift, seq._seq_meta.prefix_cache_token_lookahead) |
There was a problem hiding this comment.
[P2] Account for block-rewind requirements when selecting the only checkpoint
This boundary reserves input-shift/lookahead tokens but ignores seq.prefix_cache.recompute_overlap.recompute_blocks. For a 2049-token prompt with alignment=1024, block_size=64 and recompute_blocks=1, last-only saves state at 2048. An identical local request cannot reuse it because _find_recompute_overlap_end() requires a matching block through 2112. The earlier checkpoint at 1024 remains reusable with last-only disabled, but is no longer saved here. Please select a boundary that satisfies the actual restore requirements and add a local cold/warm regression test with recompute_blocks=1 and token_lookahead=0.
There was a problem hiding this comment.
|
LGTM |
Motivation
Chunked prefill for hybrid attention models can create multiple intermediate state checkpoints and Mooncake Store submissions within one input turn.
For append-only agent conversations, subsequent turns typically reuse the latest prefix. Saving fewer intermediate checkpoints can reduce state copies and Store writes, at the cost of fewer reusable prefixes for edited or branching conversations.
Modification
The new policy applies to hybrid attention models. Full-attention-only models ignore it.
Compatibility
The last-only policy is opt-in. The alignment default changes independently; deployments requiring the previous alignment should explicitly set:
--prefill-save-alignment 8192Earlier turns’ checkpoints remain subject to normal eviction. Snapshot-slot exhaustion retains the existing skip behavior.
MTP configurations that rewind cache hits by full blocks may require additional KV blocks beyond the saved state boundary for remote reuse. This limitation is documented.
Validation
Precision
Performance
Added test coverage for configuration propagation, chunk planning, multimodal and MTP boundaries, coordinated local/Store saves, and reuse across turns.
Benchmarked GLM-5.3-Flash FP8 on 8 × H200 with TP8 and MTP enabled:
Mooncake ON results below. TTFT changes are relative to baseline; negative values indicate lower latency.
Single-turn output is fixed at 16 tokens; multi-turn output is fixed at 512 tokens. Store bytes are successful put payloads summed across all TP ranks, with multi-turn reductions calculated over the complete conversation.
The measured benefit is reduced checkpoint and Store write volume. All paired TTFT difference 95% intervals cross zero, so this experiment does not establish a consistent single-concurrency TTFT improvement. Full-attention KV write volume remains unchanged.
The benchmark covers local prefix reuse and Store writes. Remote restoration, branching conversations, multimodal performance, and cache-pressure scenarios are outside its scope.