Skip to content

[None][feat] Support DSA MTP indexer top-k sharing#15806

Open
nvxuanyuc wants to merge 1 commit into
NVIDIA:mainfrom
nvxuanyuc:dsa_mtp_indexcache
Open

[None][feat] Support DSA MTP indexer top-k sharing#15806
nvxuanyuc wants to merge 1 commit into
NVIDIA:mainfrom
nvxuanyuc:dsa_mtp_indexcache

Conversation

@nvxuanyuc

@nvxuanyuc nvxuanyuc commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added optional Top-K reuse for sparse attention during multi-token draft iterations, improving decoding efficiency.
    • Introduced a new configuration option to enable index sharing behavior for this workflow.
  • Bug Fixes
    • Top-K results can now be preserved and reused across draft steps instead of being recomputed every time.
  • Tests
    • Added coverage for the new Top-K reuse flow in multi-step decoding scenarios.

Description

Implement GLM-5.2 IndexShare for the one-model MTP path: the indexer top-k indices are computed on the first draft step and reused for all following draft steps.

Based on #15574 for full GLM-5.2 IndexShare support - this PR covers MTP side.

A new index_share_for_mtp_iteration field is added to DeepSeekSparseAttentionConfig. It is resolved from the HF checkpoint config when left unset and threaded into the DSA indexer as mtp_index_share. On draft step 0 the per-request last-token top-k is stashed on the attention metadata; for draft steps > 0 the indexer skips the logits computation and the top-k selection, reusing the stashed indices via a copy instead.

Test Coverage

Unit testtests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py::test_indexer_decode_mtp_topk_reuse: verifies that draft step 0 stores each request's last-token top-k and that later draft steps reuse it bit-exactly (no recompute). Covered for both the steady-state generation case and the first generation step right after prefill, at BS 1 and 2.

E2E tests — in TestGLM52:

  • test_nvfp4_mtp_index_share — GSM8K accuracy (GLM-5.2-NVFP4, CuteDSL MoE, MTP 3, TEP8). Measured 93.86.
  • test_nvfp4_mtp_index_share_mtp_ar — MTP acceptance-rate guard. Measured AR 62.75%.

Accuracy A/B validation (index-share in MTP is lossless).

Dataset mtp3 index-share ON mtp3 dense topk mtp1 baseline
GSM8K (full) 94.12 94.20 93.75
LongBench (20 samples) 48.18 48.16 48.08

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@nvxuanyuc
nvxuanyuc requested review from a team as code owners July 1, 2026 00:57
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an mtp_index_share configuration option enabling reuse of DSA indexer Top-K results across MTP draft iterations instead of recomputation. Introduces metadata fields and setters for tracking skip/reuse state, stash/reuse logic in sparse_attn_indexer, Eagle3 draft-loop wiring, a corresponding llm_args config field, and a unit test.

Changes

MTP Top-K Reuse for DSA Indexer

Layer / File(s) Summary
DSA config and metadata contracts
tensorrt_llm/_torch/attention_backend/sparse/dsa.py
Adds DSAParams.mtp_index_share field, shared_topk_indices/indexer_skip_topk/in_mtp_draft_loop metadata state, set_skip_topk/set_in_mtp_draft_loop setters, and stores the flag on the Indexer instance.
Indexer Top-K reuse and stash logic
tensorrt_llm/_torch/attention_backend/sparse/dsa.py
sparse_attn_indexer reuses stashed Top-K indices when skipping is active during an MTP draft loop, otherwise computes and stashes last-token Top-K rows from generation and context sequences.
Eagle3 draft loop wiring and llm_args config
tensorrt_llm/_torch/speculative/eagle3.py, tensorrt_llm/llmapi/llm_args.py
_forward_linear_draft_loop toggles skip_topk/in_mtp_draft_loop across draft iterations when supported; DeepSeekSparseAttentionConfig gains index_share_for_mtp_iteration, threaded into DSAParams.mtp_index_share.
MTP Top-K reuse unit test
tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py
Adds test_indexer_decode_mtp_topk_reuse verifying stash creation at step 0 (next_n=2) and correct reuse at step 1 (next_n=1) via shared_topk_indices and indexer_skip_topk.

Sequence Diagram(s)

sequenceDiagram
  participant Eagle3Worker as Eagle3OneModelWorker
  participant Metadata as DSAtrtllmAttentionMetadata
  participant Indexer as Indexer.sparse_attn_indexer

  Eagle3Worker->>Metadata: set_in_mtp_draft_loop(true)
  loop draft iterations
    Eagle3Worker->>Metadata: set_skip_topk(iteration > 0)
    Eagle3Worker->>Indexer: sparse_attn_indexer(metadata)
    alt indexer_skip_topk and shared_topk_indices available
      Indexer->>Metadata: read shared_topk_indices
      Indexer-->>Eagle3Worker: reuse topk_indices_buffer
    else compute new Top-K
      Indexer->>Indexer: compute Top-K
      Indexer->>Metadata: write shared_topk_indices
    end
  end
  Eagle3Worker->>Metadata: set_skip_topk(false), set_in_mtp_draft_loop(false)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Suggested reviewers

  • ziyixiong-nv
  • aswinvisva
  • juney-nvidia
  • moraxu
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title follows the required [None][feat] format and clearly summarizes the DSA MTP top-k sharing feature.
Description check ✅ Passed The description includes a clear problem statement, solution, and test coverage; only the checklist section is omitted.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
tensorrt_llm/_torch/attention_backend/sparse/dsa.py (1)

1236-1240: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Annotate and document the new metadata setter API.

These setters are called outside this file from Eagle3, so add -> None and short Google-style docstrings.

As per coding guidelines, “Always annotate functions with return types” and “For interfaces used outside a file, prefer docstrings over comments.”

Proposed cleanup
-    def set_skip_topk(self, skip: bool):
+    def set_skip_topk(self, skip: bool) -> None:
+        """Set whether the DSA indexer should reuse shared MTP Top-K."""
         self.indexer_skip_topk = skip
 
-    def set_in_mtp_draft_loop(self, active: bool):
+    def set_in_mtp_draft_loop(self, active: bool) -> None:
+        """Set whether the current forward is inside an MTP draft loop."""
         self.in_mtp_draft_loop = active
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/attention_backend/sparse/dsa.py` around lines 1236 -
1240, The new metadata setter APIs in dsa.py are missing return annotations and
documentation; update set_skip_topk and set_in_mtp_draft_loop to explicitly
return None and add short Google-style docstrings. Keep the change localized to
these setter methods so external callers from Eagle3 can rely on the documented
interface and annotated signatures.

Source: Coding guidelines

tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py (1)

2628-2630: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for the public config wiring.

Coverage is sufficient for the raw stash/reuse path, but insufficient for DeepSeekSparseAttentionConfig.index_share_for_mtp_iteration -> DSAParams.mtp_index_share -> Indexer.mtp_index_share. Prefer setting the config field before create_indexer() instead of mutating indexer.mtp_index_share directly, or add a small conversion test in this file.

As per path instructions, test feedback should state whether coverage is sufficient or insufficient and suggest concrete test locations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py` around lines
2628 - 2630, Coverage for the public config wiring is insufficient: the test
currently mutates Indexer.mtp_index_share directly instead of verifying the
DeepSeekSparseAttentionConfig.index_share_for_mtp_iteration ->
DSAParams.mtp_index_share -> Indexer.mtp_index_share path. Update the existing
test around create_indexer() to set index_share_for_mtp_iteration on
sparse_attn_config before creating the indexer, or add a small
conversion-focused test in this file that asserts the config field is propagated
into Indexer.mtp_index_share.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/attention_backend/sparse/dsa.py`:
- Around line 1071-1072: The Top-K reuse state in DSA is currently stored in a
single shared slot on metadata, so one layer can overwrite another layer’s
indices when multiple layer-specific Indexer instances call
sparse_attn_indexer(). Update the shared_topk_indices handling in
sparse_attn_indexer and the related MTP reuse path to scope the stash by
self.layer_idx (or the local layer identity) so each layer reuses its own Top-K,
or add an explicit guard/assertion that only one DSA indexer is supported. Make
the change consistently wherever shared_topk_indices is read or written.

In `@tensorrt_llm/_torch/speculative/eagle3.py`:
- Around line 779-787: Reset the MTP Top-K state even when the draft loop fails
by wrapping the `draft_kv_cache_context` loop in a try/finally and clearing the
flags in the finally block. In `eagle3.py`, update the `self.is_mtp_eagle` /
`attn_metadata.set_skip_topk` handling inside the draft-loop section so
`set_in_mtp_draft_loop(False)` and `set_skip_topk(False)` are always restored
after `runtime_draft_len` iteration, regardless of exceptions; apply the same
cleanup pattern in the other draft-loop block referenced by the same
`reuse_mtp_topk` logic.

In `@tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py`:
- Around line 2701-2704: The sparse_attn_indexer custom Top-K test is swallowing
all failures by catching a broad Exception, which can hide real regressions.
Update the test around sparse_attn_indexer in test_dsa_indexer so it only skips
for the specific “custom topk not available” condition, or remove the try/except
entirely and let unexpected errors fail the test. Keep the logic centered on the
sparse_attn_indexer call and the use_custom_topk=True path.

---

Nitpick comments:
In `@tensorrt_llm/_torch/attention_backend/sparse/dsa.py`:
- Around line 1236-1240: The new metadata setter APIs in dsa.py are missing
return annotations and documentation; update set_skip_topk and
set_in_mtp_draft_loop to explicitly return None and add short Google-style
docstrings. Keep the change localized to these setter methods so external
callers from Eagle3 can rely on the documented interface and annotated
signatures.

In `@tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py`:
- Around line 2628-2630: Coverage for the public config wiring is insufficient:
the test currently mutates Indexer.mtp_index_share directly instead of verifying
the DeepSeekSparseAttentionConfig.index_share_for_mtp_iteration ->
DSAParams.mtp_index_share -> Indexer.mtp_index_share path. Update the existing
test around create_indexer() to set index_share_for_mtp_iteration on
sparse_attn_config before creating the indexer, or add a small
conversion-focused test in this file that asserts the config field is propagated
into Indexer.mtp_index_share.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 874ef455-3105-4c9b-bb7e-8025098a3bd4

📥 Commits

Reviewing files that changed from the base of the PR and between a721a08 and ff5300d.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/attention_backend/sparse/dsa.py
  • tensorrt_llm/_torch/speculative/eagle3.py
  • tensorrt_llm/llmapi/llm_args.py
  • tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py

Comment on lines +1071 to +1072
# MTP cross-step indexer Top-K reuse state.
self.shared_topk_indices: Optional[torch.Tensor] = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Scope shared Top-K state per indexer layer.

metadata.shared_topk_indices is a single slot, but sparse_attn_indexer() is called from layer-specific Indexer instances. With more than one DSA indexer in the MTP path, step 0’s last layer overwrites the stash and every layer in later draft steps reuses that layer’s Top-K. Key this state by self.layer_idx/local layer, or assert this path only supports one DSA indexer.

Also applies to: 2544-2552, 2798-2813

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/attention_backend/sparse/dsa.py` around lines 1071 -
1072, The Top-K reuse state in DSA is currently stored in a single shared slot
on metadata, so one layer can overwrite another layer’s indices when multiple
layer-specific Indexer instances call sparse_attn_indexer(). Update the
shared_topk_indices handling in sparse_attn_indexer and the related MTP reuse
path to scope the stash by self.layer_idx (or the local layer identity) so each
layer reuses its own Top-K, or add an explicit guard/assertion that only one DSA
indexer is supported. Make the change consistently wherever shared_topk_indices
is read or written.

Comment on lines +779 to +787
reuse_mtp_topk = (self.is_mtp_eagle
and hasattr(attn_metadata, "set_skip_topk"))
if reuse_mtp_topk:
attn_metadata.set_in_mtp_draft_loop(True)

with self.draft_kv_cache_context(attn_metadata, draft_kv_cache_manager):
for i in range(runtime_draft_len):
if reuse_mtp_topk:
attn_metadata.set_skip_topk(i > 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reset MTP Top-K flags in a finally block.

If any draft-loop operation raises, the metadata can remain in skip/reuse mode and poison the next forward with stale Top-K state.

Proposed structure
         if reuse_mtp_topk:
             attn_metadata.set_in_mtp_draft_loop(True)
 
-        with self.draft_kv_cache_context(attn_metadata, draft_kv_cache_manager):
-            for i in range(runtime_draft_len):
+        try:
+            with self.draft_kv_cache_context(attn_metadata, draft_kv_cache_manager):
+                for i in range(runtime_draft_len):
                     if reuse_mtp_topk:
                         attn_metadata.set_skip_topk(i > 0)
                     ...
-        next_draft_tokens = torch.stack(next_draft_tokens, dim=1)
-
-        if reuse_mtp_topk:
-            attn_metadata.set_skip_topk(False)
-            attn_metadata.set_in_mtp_draft_loop(False)
+            next_draft_tokens = torch.stack(next_draft_tokens, dim=1)
+        finally:
+            if reuse_mtp_topk:
+                attn_metadata.set_skip_topk(False)
+                attn_metadata.set_in_mtp_draft_loop(False)

Also applies to: 945-947

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/_torch/speculative/eagle3.py` around lines 779 - 787, Reset the
MTP Top-K state even when the draft loop fails by wrapping the
`draft_kv_cache_context` loop in a try/finally and clearing the flags in the
finally block. In `eagle3.py`, update the `self.is_mtp_eagle` /
`attn_metadata.set_skip_topk` handling inside the draft-loop section so
`set_in_mtp_draft_loop(False)` and `set_skip_topk(False)` are always restored
after `runtime_draft_len` iteration, regardless of exceptions; apply the same
cleanup pattern in the other draft-loop block referenced by the same
`reuse_mtp_topk` logic.

Comment on lines +2701 to +2704
try:
topk0 = indexer.sparse_attn_indexer(meta0, h, q, k_fp8, k_scale, w, use_custom_topk=True)
except Exception as e:
pytest.skip(f"Custom topk not available: {e}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don’t hide Top-K failures behind a broad skip.

Catching Exception here will skip on shape bugs, stale metadata, or kernel regressions. Let the test fail, or catch only the specific unavailable-custom-op error.

As per coding guidelines, “catch specific exceptions, not bare except.”

Preferred simplification
-    try:
-        topk0 = indexer.sparse_attn_indexer(meta0, h, q, k_fp8, k_scale, w, use_custom_topk=True)
-    except Exception as e:
-        pytest.skip(f"Custom topk not available: {e}")
+    topk0 = indexer.sparse_attn_indexer(meta0, h, q, k_fp8, k_scale, w, use_custom_topk=True)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
topk0 = indexer.sparse_attn_indexer(meta0, h, q, k_fp8, k_scale, w, use_custom_topk=True)
except Exception as e:
pytest.skip(f"Custom topk not available: {e}")
topk0 = indexer.sparse_attn_indexer(meta0, h, q, k_fp8, k_scale, w, use_custom_topk=True)
🧰 Tools
🪛 Ruff (0.15.20)

[warning] 2703-2703: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py` around lines
2701 - 2704, The sparse_attn_indexer custom Top-K test is swallowing all
failures by catching a broad Exception, which can hide real regressions. Update
the test around sparse_attn_indexer in test_dsa_indexer so it only skips for the
specific “custom topk not available” condition, or remove the try/except
entirely and let unexpected errors fail the test. Keep the logic centered on the
sparse_attn_indexer call and the use_custom_topk=True path.

Sources: Coding guidelines, Linters/SAST tools

@nvxuanyuc
nvxuanyuc force-pushed the dsa_mtp_indexcache branch from ff5300d to cdedd71 Compare July 1, 2026 01:03

@Superjomn Superjomn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nvxuanyuc
nvxuanyuc force-pushed the dsa_mtp_indexcache branch from cdedd71 to 3a21336 Compare July 10, 2026 05:22
@nvxuanyuc
nvxuanyuc requested review from a team as code owners July 10, 2026 05:22
@nvxuanyuc nvxuanyuc added the api-compatible Accepted LLM API contract change that is backwards-compatible label Jul 10, 2026
@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58604 [ run ] triggered by Bot. Commit: 3a21336 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58604 [ run ] completed with state SUCCESS. Commit: 3a21336
/LLM/main/L0_MergeRequest_PR pipeline #47194 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

@nvxuanyuc
nvxuanyuc force-pushed the dsa_mtp_indexcache branch from 3a21336 to 9cadc26 Compare July 12, 2026 22:46
@nvxuanyuc
nvxuanyuc requested a review from a team as a code owner July 12, 2026 22:46
@nvxuanyuc
nvxuanyuc force-pushed the dsa_mtp_indexcache branch from 9cadc26 to 2a518bb Compare July 13, 2026 00:56
@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58845 [ run ] triggered by Bot. Commit: 2a518bb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58845 [ run ] completed with state SUCCESS. Commit: 2a518bb
/LLM/main/L0_MergeRequest_PR pipeline #47397 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58953 [ run ] triggered by Bot. Commit: 2a518bb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58953 [ run ] completed with state SUCCESS. Commit: 2a518bb
/LLM/main/L0_MergeRequest_PR pipeline #47485 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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60455 [ run ] completed with state FAILURE. Commit: 25f9efb
/LLM/main/L0_MergeRequest_PR pipeline #48789 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60508 [ run ] triggered by Bot. Commit: 25f9efb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60508 [ run ] completed with state SUCCESS. Commit: 25f9efb
/LLM/main/L0_MergeRequest_PR pipeline #48832 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60607 [ run ] triggered by Bot. Commit: 25f9efb Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60607 [ run ] completed with state SUCCESS. Commit: 25f9efb
/LLM/main/L0_MergeRequest_PR pipeline #48916 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60733 [ run ] triggered by Bot. Commit: 25f9efb Link to invocation

if num_generations > 0:
next_n = num_gen_tokens // num_generations
rows = topk_indices_buffer[num_ctx_tokens:num_ctx_tokens +
num_gen_tokens][next_n - 1::next_n]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stashes topk_indices_buffer[...][next_n - 1::next_n], i.e. each gen request's last padded row. Every gen request is padded to next_n = draft_len+1 rows for cuda-graph, so any row past num_accepted sits on the target's rejected-branch continuation. Under partial acceptance (the common case at k≥7), the reuse steps at i≥1 then attend a top-k that was selected by a rejected-branch query. After the kv-lens rewind those indices also point at stale rejected-branch KV, so every reuse step of a partially accepted round is corrupted.

vLLM handles this by compacting to each request's last accepted token before the reuse steps: after set_skip_topk(True) it calls compact_topk_indices(token_indices_to_sample), where token_indices_to_sample are the last-accepted rows.

The fix here is to plumb num_accepted_tokens into the metadata and stash base + (num_accepted-1).clamp(0, next_n-1) per gen request. The context stash stays as is, and this is cuda-graph safe.

The same wrong-row pattern also shows up in the new _enable_heuristic_topk seed at line 2846. Lower severity there since it only warms up the next top-k rather than freezing it, but it wants the same num_accepted-1 selection.

See an example patch: http://nv/jvo

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Have added the fix for partial acceptance indexing and factored into a helper that heuristic topk path can reuse.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #60733 [ run ] completed with state FAILURE. Commit: 25f9efb
/LLM/main/L0_MergeRequest_PR pipeline #49020 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

Tabrizian pushed a commit to Tabrizian/TensorRT-LLM that referenced this pull request Jul 21, 2026
Squashed from NVIDIA#15806 (single commit,
PR head 25f9efb). Gated off by default (sparse_attention_config.index_share_for_mtp_iteration).

Signed-off-by: Iman Tabrizian <10105175+Tabrizian@users.noreply.github.com>
Tabrizian pushed a commit to Tabrizian/TensorRT-LLM that referenced this pull request Jul 21, 2026
… row

PR NVIDIA#15806's cross-step DSA indexer top-k stash saved topk_indices_buffer[next_n-1::next_n]
(each gen request's last padded row). TRT pads every gen request to next_n=(draft_len+1)
rows for cuda-graph capture; rows beyond num_accepted lie on the target's rejected-branch
continuation. Under partial acceptance (the majority of rounds at k>=7) the frozen indices
are then a rejected-branch query's top-k, and after the kv-lens rewind the reuse steps attend
in-loop draft KV -- a KVShare violation that corrupts every reuse step of every partially
accepted round. vLLM/SGLang compact the reuse buffer at each request's last ACCEPTED token.
Mirror that: pass num_accepted_tokens into the metadata and stash the row at
start + (num_accepted-1) per gen request (context stash unchanged). ~15 lines, cuda-graph safe.

Signed-off-by: Xiao Wang <24860335+xwang233@users.noreply.github.com>
(cherry picked from commit f074a2f98b3d60f60448857d2f0a1670a0eca6cb)
Signed-off-by: Iman Tabrizian <10105175+Tabrizian@users.noreply.github.com>
Signed-off-by: Xuanyu Chen <xuanyuc@nvidia.com>
@nvxuanyuc
nvxuanyuc force-pushed the dsa_mtp_indexcache branch from 25f9efb to e829211 Compare July 22, 2026 22:26
@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61104 [ run ] triggered by Bot. Commit: e829211 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61104 [ run ] completed with state SUCCESS. Commit: e829211
/LLM/main/L0_MergeRequest_PR pipeline #49358 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61411 [ run ] triggered by Bot. Commit: e829211 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61411 [ run ] completed with state FAILURE. Commit: e829211
/LLM/main/L0_MergeRequest_PR pipeline #49637 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61435 [ run ] triggered by Bot. Commit: e829211 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61435 [ run ] completed with state FAILURE. Commit: e829211
/LLM/main/L0_MergeRequest_PR pipeline #49659 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61496 [ run ] triggered by Bot. Commit: e829211 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61496 [ run ] completed with state SUCCESS. Commit: e829211
/LLM/main/L0_MergeRequest_PR pipeline #49715 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

@nvxuanyuc

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61524 [ run ] triggered by Bot. Commit: e829211 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #61524 [ run ] completed with state SUCCESS. Commit: e829211
/LLM/main/L0_MergeRequest_PR pipeline #49740 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-compatible Accepted LLM API contract change that is backwards-compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants