Repository navigation
Conversation
Signed-off-by: Shixiaowei02 <39303645+Shixiaowei02@users.noreply.github.com>
…ayout hooks Signed-off-by: Bo Deng <deemod@nvidia.com>
bo-nv
force-pushed
the
ri10/pr-a-page-table
branch
from
October 28, 2026 08:15
d05717c to
379248c
Compare
1 task
Collaborator
|
Thanks for consolidating layout ownership in the manager. To keep this step easy to review, could we preserve the lender’s existing contract and behavior while changing the producer? Consider staging the Tensor/Axis migration, layout-ID version bump, and stricter role admission separately, or explicitly documenting their compatibility effects. Any compatibility projection should derive from one source of truth and cover only layouts it can represent losslessly. Differential checks against the previous implementation would help verify regions, transferred buffers, shards, object keys, and admission decisions for unchanged layouts, alongside existing lifecycle regressions and real-manager GPU checks. |
This branch has not been deployed
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.
@coderabbitai summary
Description
Depends on #20534, which is not merged yet. This branch is built on #20534's head (
dbc8015261), so until #20534 merges this PR's diff also contains that commit. Please review only the last commit,379248caaa. I will rebase ontomainonce #20534 lands.This is the first of the RI-10 PRs whose goal is that a cache's layout is declared once, by its manager, and that the lender and every backend read that one description. Supporting a new cache structure then means overriding a few manager hooks.
What changes:
KVCacheManagerV2.get_page_table()builds the page table (ManagerLayout, new modulekv_cache/page_table.py). It reads what the runtime already holds: layer groups, pool groups and their pools, where each buffer lies in its slot, layer configs and the rank's place. It asks hooks only for what the runtime cannot tell, and a subclass overrides only the hooks whose answer differs:_page_buffer_tensors: how a buffer's bytes spread over ranks, as tensors whose axes split over tp/cp. The base declares K/V and their block scales by KV head and index-K replicated. A role that moves and that no hook declares makesget_page_table()fail instead of being guessed._page_untransferred_roles,_page_rebuilds_untransferred,_virtual_layers,_page_layer_ids,_page_kv_heads,_page_dtype,_page_quant_mode.page_layout:BufferDesc.tensorsreplacesmapperandgeometry. The new types areTensor,Axisandheld, with the buildershead_major,token_major,sectioned,replicatedandowned.LAYOUT_ID_VERSIONgoes from 3 to 4, so instances of different builds see different layout ids and share no pages.derive_layoutreturns the manager's table. Its own derivation from theget_disagg_*declarations and from private manager attributes is removed.What does not change: the native disaggregated transfer. It still reads the
get_disagg_*declarations, which stay for now, and so doMapperKindandRoleLayout.Follow-ups, in order:
get_disagg_*declarations.Test Coverage
tests/unittest/_torch/executor/kv_cache/sharing/test_layout_identity.py(CPU): page table construction, tensor and axis validation, layout ids (version 4 encoding), undeclared roles refused, roles that never move, layer naming, quantization.tests/unittest/_torch/executor/kv_cache/test_kvcm2_integration.py: the base manager's default tensors, and refusal of an undeclared role.tests/unittest/_torch/executor/kv_cache/sharing/test_layout_matches_native_page_table.py(GPU): the manager's page table against native's page table across model and parallel layouts.tests/unittest/_torch/executor/kv_cache/test_mamba_cache_manager.py,tests/unittest/_torch/attention/sparse/deepseek_v4/test_deepseek_v4_cache_manager.py,tests/unittest/_torch/attention/sparse/qsa/test_qsa_cache_manager_layout.py(GPU): the Mamba/KDA, DeepSeek-V4 and QSA declarations.Run locally on CPU only:
kv_cacheanddisaggregatedCPU suites match [TRTLLM-16186][feat] Lend KV cache pages and recurrent state in place #20534's results, apart from the layout tests this PR replaces.The GPU tests have not been run yet.
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.