Repository navigation
[None][fix] DFlash buffer sizing/position fixes and an accurate FlashInfer speculation gate #19466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brnguyen2
merged 9 commits into
NVIDIA:main
from
brnguyen2:upstream/dflash-serving-robustness
Sep 22, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aded16e
[None][fix] Validate DFlash buffer budgets at config time and size th…
brnguyen2 5a5436b
[None][fix] Rework the FlashInfer one-engine speculation gate as a qu…
brnguyen2 e81696d
Address trivial review comments
brnguyen2 5fe271e
[None][fix] Fix DFlash config-budget false refusals, SA gate, and err…
brnguyen2 b874cd5
[None][fix] Update DFlash config-budget tests for the new validator b…
brnguyen2 96a2bd9
[None][fix] Warn (not skip) the DFlash buffer check for TRTLLM
brnguyen2 2ef1fa9
Address trivial review comments
brnguyen2 9cf73e4
[None][fix] Re-run the DFlash buffer budget check after a Hub drafter…
brnguyen2 414ba69
[None][fix] Budget the DFlash ctx arena against pre-pool headroom whe…
brnguyen2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
79 changes: 79 additions & 0 deletions
79
tests/unittest/_torch/executor/test_py_executor_creator_flashinfer_spec_gate.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """FlashInfer qualification is independent of DFlash cache ownership. | ||
|
|
||
| DFlash remains refused for every draft backend, including those using private | ||
| buffers. Other modes retain the existing separate-manager qualification gate. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from tensorrt_llm._torch.pyexecutor.py_executor_creator import _flashinfer_one_engine_spec_supported | ||
| from tensorrt_llm._torch.speculative.interface import should_use_separate_draft_kv_cache | ||
| from tensorrt_llm.llmapi import ( | ||
| DFlashDecodingConfig, | ||
| MTPDecodingConfig, | ||
| NGramDecodingConfig, | ||
| SADecodingConfig, | ||
| ) | ||
|
|
||
| pytestmark = pytest.mark.cpu_only | ||
|
|
||
|
|
||
| def test_no_speculation_is_admitted(): | ||
| assert _flashinfer_one_engine_spec_supported("FLASHINFER", None) | ||
|
|
||
|
|
||
| def test_suffix_automaton_is_admitted_on_flashinfer(): | ||
| config = SADecodingConfig(max_draft_len=4) | ||
| assert config.spec_dec_mode.use_one_engine() | ||
| assert not config._use_shared_kv_cache | ||
| assert _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
brnguyen2 marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("backend", "uses_managed_pool"), | ||
| [("VANILLA", False), ("FA4", False), ("TRTLLM", True)], | ||
| ) | ||
| def test_dflash_is_refused_on_flashinfer(backend: str, uses_managed_pool: bool) -> None: | ||
| config = DFlashDecodingConfig(max_draft_len=7, attention_backend=backend) | ||
| assert should_use_separate_draft_kv_cache(config) is uses_managed_pool | ||
| assert not _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
| assert _flashinfer_one_engine_spec_supported("TRTLLM", config) | ||
|
|
||
|
|
||
| def test_default_dflash_is_refused_without_a_separate_manager() -> None: | ||
| config = DFlashDecodingConfig(max_draft_len=7) | ||
| assert not should_use_separate_draft_kv_cache(config) | ||
| assert not _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("backend", ["VANILLA", "FA4", "TRTLLM"]) | ||
| def test_dflash_cache_opt_out_does_not_lift_flashinfer_gate(backend: str) -> None: | ||
| config = DFlashDecodingConfig(max_draft_len=7, attention_backend=backend) | ||
| config._allow_separate_draft_kv_cache = False | ||
| assert not should_use_separate_draft_kv_cache(config) | ||
| assert not _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
|
||
|
|
||
| def test_external_drafters_are_admitted_on_flashinfer(): | ||
| config = NGramDecodingConfig(max_draft_len=4, max_matching_ngram_size=2) | ||
| assert not config.spec_dec_mode.use_one_engine() | ||
| assert _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
|
||
|
|
||
| def test_one_engine_drafters_with_a_draft_model_are_refused_on_flashinfer(): | ||
| config = MTPDecodingConfig(num_nextn_predict_layers=1) | ||
| assert config.spec_dec_mode.use_one_engine() | ||
| assert not _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
|
||
|
|
||
| def test_shared_kv_cache_is_admitted_on_flashinfer(): | ||
| config = MTPDecodingConfig(num_nextn_predict_layers=1) | ||
| config._use_shared_kv_cache = True | ||
| assert _flashinfer_one_engine_spec_supported("FLASHINFER", config) | ||
|
|
||
|
|
||
| def test_other_backends_are_not_gated(): | ||
| config = MTPDecodingConfig(num_nextn_predict_layers=1) | ||
| assert _flashinfer_one_engine_spec_supported("TRTLLM", config) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.