Repository navigation
[TRTLLM-17122][feat] Support owner-only MLA KV writes for Helix prefill - #20921
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>
zhaoyuanh-nvidia
marked this pull request as ready for review
October 24, 2026 00:36
zhaoyuanh-nvidia
requested review from
aswinvisva,
brnguyen2,
kris1025,
mzweilz,
niukuo,
schetlur-nv,
yechank-nvidia and
yunruis
October 24, 2026 00:36
This was referenced Oct 24, 2026
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
Aggregated Helix prefill runs the full prompt on every context-parallel (CP) rank for attention, but each rank must persist only the compressed MLA KV records in the cache pages it owns. Previously, prefill could write non-owned records into rank-local cache storage, so the cache was not a valid handoff to Helix decode.
This PR maps each new context token's global position to a rank-local KV slot using the Helix page ownership rule. A slot of
-1suppresses the persistent KV and scale-cache writes on non-owning ranks. The existing MLA RoPE/append operator accepts these optional slots and continues to prepare temporary Q/K for every prompt token, which dense prefill still needs to compute attention. Dense MLA performs the append/preprocessing before attention and consumes the prepared temporary K/V without appending a second time. Callers that omit the slots retain the existing behavior.Cached-context attention still requires distributed historical-KV gathering and fails explicitly until TRTLLM-17123 provides it. This PR covers owner-only persistence for dense MLA on the TRTLLM attention backend; it does not complete aggregated serving by itself. The companion #20759 provides aggregate full-prompt admission and cache allocation.
Tracks TRTLLM-17122, part of TRTLLM-16624. Design: DCP for Aggregated Workloads.
Test Coverage
tests/unittest/_torch/attention/test_helix_context_slots.pychecks the host-side global-to-local slot mapping across requests, page boundaries, and CP ranks; it is selected byl0_cpu.yml.tests/unittest/_torch/attention/multi_gpu/test_mla_helix_context.pychecks exact cache ownership, untouched non-owned storage, compact cache allocation, and direct prefill-to-decode handoff with BF16/FP8 weights and KV caches. Its distributed cases include TP1/CP2, TP2/CP2, and TP1/CP4.Validation
git diff --check, changed-file formatting/lint hooks, and DCO pass. The waiver and test-list checks pass manually with Python 3.12. The legacy-config hook reports pre-existing stale entries.PR Checklist
The description covers the motivation, behavior, scope, and validation limits.
Regression coverage exercises rank-local ownership and the prefill-to-decode cache handoff.
The new operator argument is optional for existing callers; no 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.