Repository navigation
[TRTLLM-15762][refactor] Migrate decoder execution and private resources into the runner family - #19896
Merged
lori-ren merged 14 commits intoOct 8, 2026
Conversation
Decoder buffers, graphs, forward and warmup move from PyTorchModelEngine into DecoderRunner, and EncoderDecoderRunner now composes it with the encoder stage. The engine holds a single ModelRunner. Signed-off-by: Lori Ren <lorir@nvidia.com>
DecoderRunner reads its resolved settings through self._config and no longer takes llm_args. Signed-off-by: Lori Ren <lorir@nvidia.com>
…unner DecoderRunner and NoKVCacheRunner create and update speculative metadata through shared helpers on a common config base. Gating and memoization stay with each runner. Signed-off-by: Lori Ren <lorir@nvidia.com>
The runner's static draft length read spec_config and draft limits that moved into the config. Two test stand-ins now set spec decoding through the runner config. Signed-off-by: Lori Ren <lorir@nvidia.com>
lori-ren
force-pushed
the
refactor/decoder-runner-migration
branch
from
October 6, 2026 22:49
266525b to
514656f
Compare
…oderDecoderRunner DecoderRunner keeps neutral hooks and capability flags and no longer reads is_encoder_decoder. The nine enc-dec methods move unchanged. Signed-off-by: Lori Ren <lorir@nvidia.com>
…base override The mixed path gets its own method, so EncoderDecoderRunner no longer widens the base signature. ExtraInputsCollector is exported from the decoder package. Signed-off-by: Lori Ren <lorir@nvidia.com>
Replace typing.Dict, List, Optional, Union, Tuple and Type with built-in generics and X | None. Only annotations change. Signed-off-by: Lori Ren <lorir@nvidia.com>
…ation Point stale comments at DecoderRunner, tighten runner and engine annotations, and make the shared MoE A2A warmup helpers public. Add unit tests for the split encoder-decoder warmup and input paths. Signed-off-by: Lori Ren <lorir@nvidia.com>
… config get_static_draft_len takes the spec config instead of an engine or runner config, whose draft widths are derived from it. Also drop a stale comment in DecoderRunner.model_forward. Signed-off-by: Lori Ren <lorir@nvidia.com>
lori-ren
marked this pull request as ready for review
October 7, 2026 06:20
lori-ren
requested review from
QiJune,
Shixiaowei02,
WeiHaocheng,
aswinvisva,
cascade812,
chuangz0,
lowsfer,
schetlur-nv,
thorjohnsen and
zhaoyangwang-nvidia
October 7, 2026 06:20
Contributor
Author
|
/bot run |
mzweilz
approved these changes
Oct 8, 2026
nvpohanh
approved these changes
Oct 8, 2026
YihuiLu512
approved these changes
Oct 8, 2026
jieli-matrix
approved these changes
Oct 8, 2026
xinhe-nv
approved these changes
Oct 8, 2026
QiJune
reviewed
Oct 8, 2026
QiJune
reviewed
Oct 8, 2026
Pooling and multimodal encoder runners never use speculative metadata, so drop the plumbing and fold SpecDecodeRunnerConfig back into DecoderRunnerConfig. Engine construction now raises when such a model sets speculative_config. Signed-off-by: Lori Ren <lorir@nvidia.com>
…package DecoderRunner is their only consumer, so they move to decoder/speculative.py. engine/metadata.py keeps only build_attention_metadata. Signed-off-by: Lori Ren <lorir@nvidia.com>
…exts DecoderRunner.forward and NoKVCacheRunner.forward enter inference mode and the model extra-attrs context themselves, and decoder warmup runs through forward. Engine.forward no longer sets them. Signed-off-by: Lori Ren <lorir@nvidia.com>
…nner-migration Signed-off-by: Lori Ren <lorir@nvidia.com>
Contributor
Author
|
/bot run |
lori-ren
enabled auto-merge (squash)
October 8, 2026 09:32
Collaborator
|
PR_Github #76717 [ run ] triggered by Bot. Commit: |
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
Collaborator
|
PR_Github #76717 [ run ] completed with state |
Contributor
Author
|
/bot run |
Collaborator
|
PR_Github #76732 [ run ] triggered by Bot. Commit: |
Collaborator
|
PR_Github #76732 [ run ] completed with state |
brnguyen2
added a commit
to brnguyen2/TensorRT-LLM
that referenced
this pull request
Oct 8, 2026
Main's NVIDIA#19896 moved the decoder engine internals, including _should_use_full_generation_page_table, from model_engine.py into engine/runners/decoder/runner.py. Move this branch's extracted uses_full_generation_page_table helper along with it: it now lives in runner.py next to the method, and the executor creator imports it from there. Semantics unchanged on both paths. Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
1 task done
vsabavat
added a commit
to vsabavat/TensorRT-LLM
that referenced
this pull request
Oct 9, 2026
Main's NVIDIA#19896 (2681ed1) moved PyTorchModelEngine's decoder execution into DecoderRunner (engine/runners/decoder/runner.py) and the encoder-decoder fast path into EncoderDecoderRunner, so this branch's model_engine.py changes conflicted. model_engine.py is main's; the branch's changes move to where that code now lives: - DecoderRunner, from NVIDIA#19816 (U1): the step-copy gather, the staged previous batch / position indices, gather_ids written by copy_to_device_if_changed, no num_accepted_draft_tokens buffer, and the CUDA graphs' static inputs; from NVIDIA#19814 (U3): the gather of vocabulary-sharded logits for post-processors. - EncoderDecoderRunner: its previous_batch_indices_cuda write clears the staged batch indices. - The two tests that called the moved members call the runner. Main's other commits since f891b3d: NVIDIA#19484, NVIDIA#19892, NVIDIA#19409, NVIDIA#19553, NVIDIA#19957, NVIDIA#19749, NVIDIA#19585, NVIDIA#19766, NVIDIA#19963, NVIDIA#19588, NVIDIA#19600, NVIDIA#19825, NVIDIA#19821, NVIDIA#19930, NVIDIA#18485. Signed-off-by: Vasanth Sabavat <vsabavat@nvidia.com>
1 task done
1 task done
3 of 5 tasks
1 task done
1 task done
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.
Dev Engineer Review
The available diff changes only import formatting in
model_engine.pyandtest_pytorch_model_engine.py. It shows no executable behavior, API, or configuration changes. The broader runner migration described in the PR context is not present in this diff, so its implementation cannot be assessed from the available evidence.QA Engineer Review
The only test file in the available diff is
tests/unittest/_torch/executor/test_pytorch_model_engine.py. Its changes reformat imports and do not alter test cases or assertions. No test-list files changed. BART, T5, and Whisper integration tests appear in CI test lists, but the available diff does not show changes to those integration tests. Coverage verdict: needs follow-up for the runner migration described in the PR context; test execution results are unavailable.Per-File QA Perspective
tensorrt_llm/_torch/pyexecutor/model_engine.py: Import formatting changed. No behavior change is visible in the diff.tests/unittest/_torch/executor/test_pytorch_model_engine.py: Import formatting changed. No test behavior change is visible in the diff.Description
This PR moves decoder execution out of
PyTorchModelEngineintoDecoderRunner(engine/runners/decoder/). Every model now resolves to a runner, and_fallback_to_engineis removed.DecoderRunnerowns decoder input preparation, forward, warmup and CUDA graph capture, along with the buffers and metadata memos they use. It reads its settings from the frozenDecoderRunnerConfig, including the three values previously read fromllm_args.EncoderDecoderRunnerextendsDecoderRunnerand composes the encoder stage, renamedEncoderStage, which keeps its own worker, stream and graphs. Cross-KV projection and dummy requests, mixed CUDA graph capture and cross-attention inputs move into it.DecoderRunnerno longer checksis_encoder_decoderand exposes capability flags and hooks instead.enable_encoder_decoder_mixed_cuda_graphmoves toEncoderDecoderRunnerConfig.SpecDecodeRunnerConfigand helpers inengine/metadata.py.get_static_draft_lentakes the spec config.attn_metadata,spec_metadata,cuda_graph_runner, graph release, late-install setters,forward_encoderand encoder warmup) forward to the runner.Two orderings change: releasing graphs frees decoder graphs before the compile backend's piecewise graphs, and warmup dummy batches free their cross-KV blocks before the other cache managers.
Test Coverage
tests/unittest/_torch/executor/engine/test_runners.pytests/unittest/_torch/executor/engine/test_encoder_decoder.pytests/unittest/_torch/executor/engine/test_metadata.pytests/unittest/_torch/executor/test_pytorch_model_engine.pytests/unittest/_torch/executor/test_pytorch_model_engine_warmup.pytests/unittest/_torch/executor/test_eager_workspace_engine.pytests/unittest/_torch/executor/kv_cache/test_kvcm2_integration.pytests/unittest/_torch/speculative/(MTP, Eagle3, PARD, draft-target, ngram with CUDA graphs)tests/integration/defs/llmapi/test_llm_api_pytorch_{bart,t5,whisper}.pytests/unittest/llmapi/test_llm_multi_gpu_pytorch.py::test_tinyllama_logits_processor_2gpuPR 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.