Repository navigation
[TRTLLM-17123][feat] Gather cached MLA KV for Helix prefill - #20924
Merged
zhaoyuanh-nvidia merged 1 commit intoOct 24, 2026
Merged
zhaoyuanh-nvidia merged 1 commit into
zhaoyuanh-nvidia merged 1 commit into
Conversation
Signed-off-by: Zhaoyuan He <195028209+zhaoyuanh-nvidia@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Helix aggregate chunked prefill must attend to earlier MLA KV records that are stored across context-parallel (CP) ranks. Before this change, a cached context could not reconstruct its full token history from its rank-local persistent cache.
This PR derives each rank's owned read intervals from the existing global history-chunk plan, loads the corresponding compressed KV records, and uses the variable-size CP all-gather to assemble each bounded history chunk. Every rank participates in the same collective sequence, including iterations where it contributes zero records. FP8 cache records are dequantized locally to the query dtype before communication. A CUDA reorder operator restores request and token order, then separates compressed KV from the shared RoPE key segment (
k_pe) for the existing MLA expansion, attention, and softmax-merge path. Persistent KV remains sharded.Cached Helix contexts require chunked prefill on SM100 or newer; the unsupported nonchunked path fails explicitly. This PR supplies historical-KV gathering for dense MLA. Request admission, owner-only writes, and initial KV allocation are provided by #20923, #20921, and #20920 on the feature branch. Full-checkpoint aggregate serving, prefix reuse, and performance remain integration work.
Tracks TRTLLM-17123, part of TRTLLM-16624. Design: DCP for Aggregated Workloads.
Test Coverage
tests/unittest/_torch/attention/kernels/test_mla_helix_reorder.pychecks exact record ordering and K/k_pesplitting for FP16, BF16, and FP32, including empty requests and page/cycle boundaries.tests/unittest/_torch/attention/multi_gpu/test_mla_helix_context.pychecks multiple real prefill chunks, unequal and empty CP contributions, BF16/FP8 weights and KV storage, TP/CP layouts, exact cache ownership, mixed context/decode batches, metadata restoration, and direct decode handoff.unittest/_torch/attentionselection.Validation
feat/helix-agghead and has the same stable patch ID as the validated seven-file implementation. Python syntax,git diff --check, changed-file formatting/lint hooks, and the waiver and AST test-list checks pass. The repository-wide legacy-config hook reports pre-existing stale entries; the two test-list hooks were rerun successfully with Python 3.12 because the Windows hook uses Python 3.9.PR Checklist
The description covers the motivation, behavior, scope, and validation limits.
Regression coverage exercises the reorder operator and distributed cached-history handoff.
No user-facing configuration, dependency, or ownership changes are introduced.
Attention, runtime, and kernel owners are appropriate reviewers.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see the available CI bot commands, comment
/bot help.