Skip to content

[https://nvbugs/6451032][fix] Reserve extra dflash context slot for dummy requests#16548

Open
amukkara wants to merge 1 commit into
NVIDIA:mainfrom
amukkara:dflash-padding
Open

[https://nvbugs/6451032][fix] Reserve extra dflash context slot for dummy requests#16548
amukkara wants to merge 1 commit into
NVIDIA:mainfrom
amukkara:dflash-padding

Conversation

@amukkara

@amukkara amukkara commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved speculative decoding handling for unknown or temporary requests by assigning them to a dedicated scratch slot, preventing incorrect reuse of the first active slot.
    • Increased internal slot capacity to support safer request mapping during warmup, padding, and context processing.
  • Tests

    • Removed waivers for DFlash Qwen3.5 integration tests, allowing both parameterized scenarios to run normally.

Description

Problem: DFlash keeps a per-request context K/V cache indexed by a slot. With cuda graph padding enabled, the padding requests defaulted to slot 0 corrupting whichever real request happened to occupy slot 0. This caused non-deterministic acceptance-length collapse (one request in a batch dropping from ~3.0 to ~0.55) and made test_dflash_qwen3_5_4b flaky.

Solution: Reserve one extra scratch slot for dummy requests. _ctx_len and the K/V buffers are now sized max_batch + 1, with _dummy_slot = max_batch. Real requests still only draw slots 0..max_batch-1.

Test Coverage

unittest/_torch/speculative/hw_agnostic/test_dflash.py::test_dflash_qwen3_5_4b
Increase acceptance length threshold in dflash unit tests to catch future regressions early.

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.

@amukkara
amukkara marked this pull request as ready for review July 17, 2026 19:03
@amukkara
amukkara requested review from a team as code owners July 17, 2026 19:03
@amukkara amukkara changed the title [https://nvbugs/6451032][fix] Reserve extra dflash KV slot for dummy requests [https://nvbugs/6451032][fix] Reserve extra dflash context slot for dummy requests Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

DFlash speculative decoding now uses an additional dummy slot for unknown request IDs, including warmup and CUDA graph padding. Context-length and K/V buffers accommodate the extra slot, and two DFlash integration test waivers are removed.

Changes

DFlash dummy-slot handling

Layer / File(s) Summary
Reserve dummy-slot buffers
tensorrt_llm/_torch/speculative/dflash.py
DFlash reserves an extra slot at max_batch and allocates context-length and K/V buffers for max_batch + 1 slots.
Route unknown requests to dummy slot
tensorrt_llm/_torch/speculative/dflash.py, tests/integration/test_lists/waives.txt
Request mappings during preparation and post-prefill reconstruction use the dummy slot for missing IDs, and two DFlash test waiver entries are removed.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Suggested reviewers: zhaoyangwang-nvidia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 ticket/type format and clearly describes the DFlash dummy-slot fix.
Description check ✅ Passed The description includes the problem, solution, test coverage, and checklist completion, so it is mostly complete.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@amukkara
amukkara requested a review from ziyixiong-nv July 17, 2026 19:08
Signed-off-by: Anurag Mukkara <134339030+amukkara@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant