Skip to content

[TRTLLM-16722][feat] Dflash Unified KVCache - #20486

Merged
allisonlim-nv merged 47 commits into
NVIDIA:mainfrom
allisonlim-nv:feat/dflash-unified-kv
Nov 3, 2026
Merged

allisonlim-nv merged 47 commits into
NVIDIA:mainfrom
allisonlim-nv:feat/dflash-unified-kv

Conversation

@allisonlim-nv

@allisonlim-nv allisonlim-nv commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Dev Engineer Review

  • KvCacheCreator can place eligible DFlash target and draft layers in one V2 KV cache manager. The launcher enables this path only when context and generation configurations meet compatibility gates. Check the gates against layer ownership, dtype, and page geometry.
  • DFlash now binds to unified-manager allocation metadata and block offsets. Unsupported unified layouts raise errors; separate-manager layouts can use the private-arena fallback. Verify allocation, reuse, and context-slot behavior on both paths.
  • Peer registration rejects mismatched unified draft-layer counts. This adds a compatibility check before registration.
  • The supplied CI reports include successes and failures, but do not establish successful execution of the current changes. Test execution status is therefore unavailable. The author provided a performance-results link, but the measurements were not included in the supplied evidence.

QA Engineer Review

New and modified tests cover unified-cache eligibility and launcher configuration, cache-manager layer-spec forwarding, mixed-format block-table indexing, peer compatibility, RankInfo serialization, and block-table offset decoding. The disaggregated DFlash accuracy test is listed in tests/integration/test_lists/test-db/l0_dgx_b200.yml; no matching manual-QA entry was identified. Coverage verdict: needs follow-up. The supplied CI reports do not identify specific failures or confirm successful execution across the changed paths.

Per-File QA Perspective

  • tensorrt_llm/_torch/disaggregation/native/peer.py — Verify that mismatched num_draft_layers values reject registration and matching values allow registration.
  • tensorrt_llm/_torch/disaggregation/native/rank_info.py — Verify draft-layer counts for unified and legacy layouts, including serialization and the default for older payloads.
  • tensorrt_llm/_torch/pyexecutor/_util.py — Verify unified-layout eligibility, target and draft storage specifications, cache-cost estimation, and fallback to separate draft-cache creation.
  • tensorrt_llm/_torch/pyexecutor/scheduler/scheduler_v2.py — The change updates a comment only. Confirm that its description of disaggregated KV transfer matches runtime behavior.
  • tensorrt_llm/_torch/speculative/dflash.py — Verify unified and separate manager binding, slot initialization, block offsets, and errors for unsupported unified layouts.
  • tensorrt_llm/_torch/speculative/interface.py — Verify draft metadata handling when the target manager also provides the draft-cache view.
  • tensorrt_llm/_torch/speculative/utils.py — Verify that the target manager is not returned as a separate draft manager.
  • tensorrt_llm/_torch/speculative/spec_tail_kernels.py — Verify that block_offset is applied before counting and decoding draft block-table entries.
  • tensorrt_llm/commands/serve.py — Verify that shared draft KV is enabled only when context and generation configurations satisfy the compatibility gates.
  • tests/integration/defs/accuracy/references/acceptance_length.yaml — Adds the reference and minimum threshold for the unified DFlash accuracy test. The integration test is listed in the B200 CI test list.
  • tests/integration/defs/accuracy/test_disaggregated_serving.py — Adds TestQwen3_8BDFlash::test_gsm8k_1p1d_unified_draft_kv for accuracy and acceptance length. The test is listed in the B200 CI test list; no matching manual-QA entry was identified.
  • tests/integration/test_lists/test-db/l0_dgx_b200.yml — Adds the unified DFlash accuracy test to the B200 CI list.
  • tests/unittest/_torch/executor/kv_cache/test_dflash_unified_kv_gate.py — Covers unified-layout eligibility and launcher decisions across configuration cases. No integration test-list entry applies.
  • tests/unittest/_torch/executor/kv_cache/test_kv_cache_estimation.py — Covers forwarding per-layer storage specifications to cache-manager construction. No integration test-list entry applies.
  • tests/unittest/_torch/executor/kv_cache/test_kvcm2_integration.py — Covers DFlash context block-table indices with FP8 target storage and BF16 draft storage. No integration test-list entry applies.
  • tests/unittest/disaggregated/test_peer.py — Covers peer registration with matching and mismatched draft-layer counts. No integration test-list entry applies.
  • tests/unittest/disaggregated/test_rank_info.py — Covers manager-derived and serialized RankInfo draft-layer counts, including older payloads. No integration test-list entry applies.
  • tests/unittest/_torch/speculative/test_spec_tail_kernels.py — Covers block-table decoding with zero and nonzero offsets. No integration test-list entry applies.
  • tests/unittest/_torch/executor/kv_cache/test_kv_cache_budget_split.py — Sets the DFlash mode mock explicitly in the target-cost test. No integration test-list entry applies.
  • tests/unittest/_torch/speculative/hw_agnostic/test_dflash_copy_skip.py — Updates the slot-assignment stub and comment used by copy tests. No integration test-list entry applies.

Description

Follow-up to #20178. Integrate DFlash with the unified key-value cache manager so target and draft layers share one manager while retaining their respective cache data types.

Test Coverage

The following 24 comparisons cover tensor parallel configurations, CUDA graphs, overlap scheduling, attention data parallelism, and mixed cache precision.

All result columns report AL. Measurements come from the generation server’s /metrics, except the attention data parallelism comparisons, which use per-request statistics from a concurrent client. Both configuration columns show tensor parallel sizes; the disaggregated configuration lists prefill → decode.

Test configuration Aggregated configuration Disaggregated configuration Aggregated before Aggregated after Disaggregated before Disaggregated after
CUDA graphs enabled; overlap scheduler enabled 1 1 → 1 3.8180 3.8180 3.1793 3.8180
CUDA graphs enabled; overlap scheduler enabled 2 2 → 2 3.8646 3.8646 3.3140 3.8646
CUDA graphs enabled; overlap scheduler enabled 1 2 → 1 3.8180 3.8180 3.2437 3.8284
CUDA graphs enabled; overlap scheduler enabled 2 1 → 2 3.8646 3.8646 3.0522 3.6005
CUDA graphs enabled; overlap scheduler enabled 4 2 → 4 3.5928 3.5928 2.9582 3.4645
CUDA graphs enabled; overlap scheduler disabled 1 1 → 1 3.6360 3.6360 3.0302 3.6360
CUDA graphs enabled; overlap scheduler disabled 2 1 → 2 3.6973 3.6973 2.9202 3.4406
CUDA graphs enabled; overlap scheduler disabled 1 2 → 1 3.6360 3.6360 3.0928 3.6395
CUDA graphs enabled; overlap scheduler disabled 4 2 → 4 3.4499 3.4499 2.8491 3.3349
CUDA graphs disabled; overlap scheduler enabled 1 1 → 1 3.7645 3.7645 3.2793 3.7645
CUDA graphs disabled; overlap scheduler enabled 2 1 → 2 3.5380 3.5380 3.3256 3.8240
CUDA graphs disabled; overlap scheduler enabled 1 2 → 1 3.7645 3.7645 3.0041 3.4615
CUDA graphs disabled; overlap scheduler enabled 4 2 → 4 3.5565 3.5565 3.3079 3.8810
CUDA graphs disabled; overlap scheduler disabled 1 1 → 1 3.5856 3.5856 3.1083 3.5856
CUDA graphs disabled; overlap scheduler disabled 2 1 → 2 3.3938 3.3938 3.1842 3.6538
CUDA graphs disabled; overlap scheduler disabled 1 2 → 1 3.5856 3.5856 2.8926 3.3511
CUDA graphs disabled; overlap scheduler disabled 4 2 → 4 3.4255 3.4255 3.1556 3.7135
Attention data parallelism 2 2 → 2 3.7766 3.7766 3.1109 3.6687
Attention data parallelism 4 2 → 4 3.5341 3.5269 2.9660 3.5495
Mixed cache precision 1 1 → 1 3.7690 3.7690 3.2181 3.7690
Mixed cache precision 2 2 → 2 3.8874 3.8874 3.3286 3.8874
Mixed cache precision 2 1 → 2 3.8874 3.8874 3.2567 3.7878
Mixed cache precision 1 2 → 1 3.7690 3.7690 3.2178 3.7714
Mixed cache precision 4 2 → 4 3.6799 3.6799 3.0542 3.4708

The mixed cache precision runs use the following configuration. Here, bfloat16 denotes the 16-bit brain floating-point format.

Model Weights Key-value cache
Target: Qwen3-8B bfloat16 8-bit floating point
Drafter: Qwen3-8B-DFlash-b16 bfloat16 bfloat16

Only the target cache uses 8-bit floating point; target weights and activations remain bfloat16. Runtime logs confirm the intended target and draft cache types on every rank, with the drafter using the shared bfloat16 pool and no fallback to its private cache. Transfer unit coverage verifies that draft pages use two-byte elements even when the servers advertise the target cache’s one-byte element size.

Results:

  • Aggregated AL is unchanged in 23 of 24 comparisons. The attention data parallelism comparison at tensor parallel size 4 changes by −0.20%; this run uses a timing-dependent concurrent client.
  • Disaggregated AL increases in all 24 comparisons.
  • After the change, aggregated and disaggregated AL match exactly whenever prefill and decode use the same tensor parallel size without attention data parallelism.
  • Other configurations can produce different generated text. Among requests with identical output, aggregated and disaggregated AL agree within approximately ±1%, except the mixed cache precision configuration with prefill size 2 and decode size 4, where the difference is −1.89%.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

Separate NVFP4 data and block scales from other equal-size buffers while keeping shared lifecycle slot allocation. Preserve matching role order and require matching scale roles.

Add one regression test for mixed NVFP4 and BF16 storage, checking scale addresses at slot 1 and the final slot.

Signed-off-by: Allison Lim <[email protected]>
Read the data-only view of three-dimensional pointer tables for non-FP4 layers while preserving NVFP4 scale handling and legacy two-dimensional tables.

Add one native-binding regression covering mixed BF16/NVFP4 pointer tables and legacy BF16 tables.

Signed-off-by: Allison Lim <[email protected]>
Preserve explicit and legacy layer configuration while applying upstream pool rebalancing settings to both paths.

Signed-off-by: Allison Lim <[email protected]>
@allisonlim-nv allisonlim-nv changed the title Feat/dflash unified kv [TRTLLM-20434][feat] Dflash Unified KVCache Oct 16, 2026
@allisonlim-nv
allisonlim-nv marked this pull request as ready for review October 16, 2026 18:55
@allisonlim-nv
allisonlim-nv requested review from a team as code owners October 16, 2026 18:55

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82037 [ run ] triggered by Bot. Commit: a5ce92e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82039 [ run ] triggered by Bot. Commit: a5ce92e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82037 [ run ] completed with state ABORTED. Commit: a5ce92e

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82039 [ run ] completed with state FAILURE. Commit: a5ce92e
/LLM/main/L0_MergeRequest_PR pipeline #67676 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor Author

/bot run --reuse-test 67676 --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82085 [ run ] triggered by Bot. Commit: a5ce92e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82085 [ run ] completed with state FAILURE. Commit: a5ce92e
/LLM/main/L0_MergeRequest_PR pipeline #67722 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor Author

/bot run --reuse-test 67722 --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82194 [ run ] triggered by Bot. Commit: a5ce92e Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82194 [ run ] completed with state SUCCESS. Commit: a5ce92e
/LLM/main/L0_MergeRequest_PR pipeline #67824 completed with status: 'SUCCESS'

CI Report

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82238 [ run ] triggered by Bot. Commit: e1f1fb1 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82238 [ run ] completed with state FAILURE. Commit: e1f1fb1
/LLM/main/L0_MergeRequest_PR pipeline #67868 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@allisonlim-nv

Copy link
Copy Markdown
Contributor Author

/bot run --reuse-test 67868 --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82321 [ run ] triggered by Bot. Commit: e1f1fb1 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #82321 [ run ] completed with state SUCCESS. Commit: e1f1fb1
/LLM/main/L0_MergeRequest_PR pipeline #67943 completed with status: 'SUCCESS'

CI Report

Link to invocation

@allisonlim-nv
allisonlim-nv merged commit d07468b into NVIDIA:main Nov 3, 2026
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 4, 2026
No tree change: the update only merges main up to 1f08014, already in via NVIDIA#21400.

Signed-off-by: Zhenhuan Chen <[email protected]>
jvpflum added a commit to jvpflum/TensorRT-LLM that referenced this pull request Nov 4, 2026
Resolve the conflict with NVIDIA#20486 (Dflash Unified KVCache), NVIDIA#21281 and NVIDIA#21367.
The unified and paged pools address a reused prefix themselves, so the tracker
stays off there; the VANILLA dense arena still starts a prefix hit from the
uncached tail. Adapt to the new _assign_slot(..., bases) and
_write_ctx_len(updates, bases) API.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Juice <[email protected]>
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 7, 2026
Merge origin/main ecf1fef (124 commits over 745c1ce). NVIDIA#21399,
NVIDIA#21400, NVIDIA#20486 and NVIDIA#20664 are now in main: their files take main's
reviewed version with this branch's later commits re-applied (fused FC12
reserved_sms + die_major, DFlash slot base pages + helix shard, DSpark
shift_label, prequantized MXFP8 over the whole low-M GEMM range).
NVIDIA#21067 and NVIDIA#20535 stay as [DEPS] merges.

Schemas and the llm_args golden manifest are merged by hand.

Signed-off-by: Zhenhuan Chen <[email protected]>
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 8, 2026
Signed-off-by: Zhenhuan Chen <[email protected]>
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 8, 2026
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 8, 2026
No tree change: the update only merges main up to 1f08014, already in via NVIDIA#21400.

Signed-off-by: Zhenhuan Chen <[email protected]>
dc3671 added a commit to dc3671/TensorRT-LLM that referenced this pull request Nov 8, 2026
Merge origin/main ecf1fef (124 commits over 745c1ce). NVIDIA#21399,
NVIDIA#21400, NVIDIA#20486 and NVIDIA#20664 are now in main: their files take main's
reviewed version with this branch's later commits re-applied (fused FC12
reserved_sms + die_major, DFlash slot base pages + helix shard, DSpark
shift_label, prequantized MXFP8 over the whole low-M GEMM range).
NVIDIA#21067 and NVIDIA#20535 stay as [DEPS] merges.

Schemas and the llm_args golden manifest are merged by hand.

Signed-off-by: Zhenhuan Chen <[email protected]>
jvpflum added a commit to jvpflum/TensorRT-LLM that referenced this pull request Nov 9, 2026
Resolve the conflict with NVIDIA#20486 (Dflash Unified KVCache), NVIDIA#21281 and NVIDIA#21367.
The unified and paged pools address a reused prefix themselves, so the tracker
stays off there; the VANILLA dense arena still starts a prefix hit from the
uncached tail. Adapt to the new _assign_slot(..., bases) and
_write_ctx_len(updates, bases) API.

Signed-off-by: Juice <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants