Repository navigation
[TRTLLM-15766][refactor] Decouple decoder tests from private methods and split DecoderRunner by phase - #20134
Conversation
Graph selection, promoted-context, overlap and MRoPE tests run the real runner through engine.forward, stubbing only the CUDA graph runner. Signed-off-by: Lori Ren <[email protected]>
Check the graph lookup's arguments instead of patching the selector by module path, and stub release_graphs instead of the private graph release. Signed-off-by: Lori Ren <[email protected]>
…ffers The decoder runner's persistent input buffers move into one dataclass that allocates them in the same order. Signed-off-by: Lori Ren <[email protected]>
The distributed warmup agreement moves out of DecoderRunner into a class built from dist and mapping. Signed-off-by: Lori Ren <[email protected]>
Attention and speculative metadata memos move into DecoderMetadata; the runner delegates attn_metadata and spec_metadata to it. Signed-off-by: Lori Ren <[email protected]>
Warmup and capture dummy requests move into DummyRequestFactory, which takes the runner's dummy-request hooks as bound methods. Signed-off-by: Lori Ren <[email protected]>
CUDA graph runners, capture, and no_cuda_graph move into DecoderCudaGraphs; the runner exposes the two graph runners as read-only properties. Signed-off-by: Lori Ren <[email protected]>
Input preparation and the steady-gen cache move into DecoderInputPreparer; the runner delegates guided_decoder to it. Signed-off-by: Lori Ren <[email protected]>
…paration prepare_inputs and the fast-path hooks return PreparedInputs instead of tuples; the runner resolves the tree draft length itself. Signed-off-by: Lori Ren <[email protected]>
…uts hook Steady-gen reuse and context promotion turn off when the runner has an extra-inputs hook; the encoder-decoder runner overrides eager workspace reclamation instead of setting flags. Signed-off-by: Lori Ren <[email protected]>
…er metadata DecoderMetadata.set_up_attn/set_up_spec become setup_attention/setup_speculative, and the speculative.py helpers move into metadata.py; resolve_runtime_draft_len moves to inputs.py. Signed-off-by: Lori Ren <[email protected]>
Fold _prepare_tp_inputs into prepare_inputs and split it into DecoderInputPreparer stage methods sharing a per-pass HostInputs accumulator. Signed-off-by: Lori Ren <[email protected]>
Move decoder warmup into a DecoderWarmup component built from the runner's components. Derive the encoder-decoder warmup differences from the extra-inputs hook. Signed-off-by: Lori Ren <[email protected]>
Move encoder-decoder input preparation into its own component and share the padding and model-input tail with the decoder preparer. Signed-off-by: Lori Ren <[email protected]>
…putPreparer The forward-time position and KV-length corrections now live with the input buffers they read. Signed-off-by: Lori Ren <[email protected]>
Dummy batch release and mixed context rows move into DummyRequestFactory, and encoder-decoder capture moves into its own component. Signed-off-by: Lori Ren <[email protected]>
…ted iter states out of DecoderRunner The greedy-sample group sync is a metadata function, and the preparer owns the input copy event and every iter_states write. Signed-off-by: Lori Ren <[email protected]>
…erCudaGraphs LoRA graph choice, final-context promotion and the eager, breakable, capture and replay dispatch now live with the graph runners. Signed-off-by: Lori Ren <[email protected]>
Comments added upstream still named DecoderRunner methods that moved into components. Signed-off-by: Lori Ren <[email protected]>
Context warmups, context-row promotion, steady-generation reuse, eager workspace reclaim and deferred decode outputs each get their own flag again instead of following the extra-inputs hook. Signed-off-by: Lori Ren <[email protected]>
… factories Encoder-decoder behaviour moves into component subclasses instead of runner hooks, and one LoRA builder holds the LoRA state. Signed-off-by: Lori Ren <[email protected]>
…udaGraphs The runner selects, pads and runs graphs through the component, which also owns the two-pass warmup and capture. Signed-off-by: Lori Ren <[email protected]>
… runner Warmup returns the eager workspace reclaimer and marks JIT warmup forwards through the forward hook. Signed-off-by: Lori Ren <[email protected]>
…are the padding tail DecoderInputBuffers extends the frozen engine buffers, and the decoder and no-KV-cache runners pad through common helpers. Signed-off-by: Lori Ren <[email protected]>
… signatures Preparation reports the step's draft length and keeps its lists in a frozen group; constructors are keyword-only and returns annotated. Signed-off-by: Lori Ren <[email protected]>
Rank agreement only serves the warmup phase, so it lives with DecoderWarmup again. Signed-off-by: Lori Ren <[email protected]>
|
/bot run |
|
PR_Github #77244 [ run ] triggered by Bot. Commit: |
|
PR_Github #77244 [ run ] completed with state
|
Port the generation-only autotuner warmup for Helix CP into DecoderWarmup, and its test onto the component. Signed-off-by: Lori Ren <[email protected]>
|
/bot run --disable-fail-fast |
|
PR_Github #78651 [ run ] triggered by Bot. Commit: |
|
PR_Github #78651 [ run ] completed with state
|
Keep the renamed helix waive alongside the new compile-bypass waives. Signed-off-by: Lori Ren <[email protected]>
|
/bot run --disable-fail-fast |
|
PR_Github #78666 [ run ] triggered by Bot. Commit: |
|
PR_Github #78666 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78747 [ run ] triggered by Bot. Commit: |
|
PR_Github #78747 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78797 [ run ] triggered by Bot. Commit: |
|
PR_Github #78797 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78853 [ run ] triggered by Bot. Commit: |
|
PR_Github #78853 [ run ] completed with state |
Resolve the conflict with NVIDIA#20134, which moved warmup out of DecoderRunner: the MiniMax-M3 MSA indexer prewarm now lives in DecoderWarmup (decoder/warmup.py). Signed-off-by: Zheyu Fu <[email protected]>
Resolve runner.py after NVIDIA#20134 split DecoderRunner by phase: the model's runtime hooks now reach the phase that uses them. The runner keeps the step scopes, the graph-runner config and the greedy-token logits; the input preparer the H2D skip copies, the step-input pack and the speculative step fold; the metadata the MSA policy and the greedy RNG upload skip; the graphs the short/long split and the post-capture tactic merge; the warmup the post-autotune tactic merge (through runtime_hooks_of). Signed-off-by: peihengh <[email protected]>
Upstream NVIDIA#20134 moved the decoder warmup out of DecoderRunner into DecoderWarmup (warmup.py) and the two-pass CUDA graph capture into DecoderCudaGraphs.warmup_and_capture; NVIDIA#20246 replaced the steady-state MoE all-to-all budget with the serving-timeout switch around the capture pass. The pre-capture JIT warmup barrier moves with them: DecoderWarmup runs the drain and rank sync before warmup_and_capture, and the barrier test drives DecoderWarmup.run with the graph passes and the timeout switch recorded. Signed-off-by: Aaron Meoded <[email protected]>
…els branch Merge k3-cons/b-runtime 7487caf, which carries the decoder refactor from main (NVIDIA#20134) and the maintainer fixture fixes. No conflicts. Signed-off-by: Vasanth Sabavat <[email protected]>
The main merge moved DecoderRunner._preprocess_inputs to DecoderInputPreparer.preprocess_inputs (NVIDIA#20134); the test still built a DecoderRunner, so every case failed with an AttributeError. Build the input preparer instead, with the overlap offsets under its buffers. Signed-off-by: peihengh <[email protected]>
Main split DecoderRunner by phase (NVIDIA#20134): warmup moved to decoder/warmup.py (DecoderWarmup) and CUDA graph capture to decoder/graphs.py (DecoderCudaGraphs). The PR's warmup changes move with them: - DecoderWarmup._warmup_scheduled starts the sampling-module and MXFP8 FlashInfer helpers, calls before_warmup_forwards_callable after the pre-JIT prewarms, and joins the helpers before CUDA graph capture (_warmup_scheduled_forwards, _join_sampling_module_build). DecoderRunner.before_warmup_forwards_callable forwards to it. - _tunes_flashinfer_mxfp8 / flashinfer_mxfp8_pass_selected move to DecoderWarmup; DecoderRunner.flashinfer_mxfp8_pass_selected keeps its classmethod signature for jit_prefetch.tunes_flashinfer_mxfp8_at_load, passing the runner class's _context_warmups_supported. The MXFP8 helper starts only with compile ahead on. - The DSA paged_mqa_logits_metadata skip, the context-only gen FMHA grid skip (through main's trtllm_gen_jit_warmup argument) and the Mamba tune-ahead pass selection move to DecoderWarmup. - The once-per-shape FlashInfer MXFP8 decode-graph tuning moves to DecoderCudaGraphs. - Main restores the DSv4 indexer-Q CuTe DSL prewarm with a working import path (NVIDIA#20253); it is kept. Other conflicts: - glm_kpool/backend.py: main adds the native FP8 TRTLLM-GEN decode path; the BF16 branch keeps native_decode_geometry, which jit_prefetch's fmha_gen planner shares. - test_distributed_warmup_oom.py: the Mamba tune-ahead test runs on main's DecoderWarmup fixture. Main moved the CuTe DSL kernels out of _torch/cute_dsl_kernels (NVIDIA#19275); jit_prefetch_cute_dsl.py imports them from _torch/kernels and _torch/attention/kernels. The PR's runner tests now target DecoderWarmup and DecoderCudaGraphs. Signed-off-by: chenfeiz0326 <[email protected]>
Dev Engineer Review
The refactor moves decoder input preparation, metadata, dummy-request creation, CUDA-graph handling, and warmup into dedicated components.
DecoderRunnerdelegates those responsibilities and retains its forward path and public entry points.EncoderDecoderRunnersupplies specialized components.common.pyadds shared token-padding and model-input helpers.PreparedInputsgainsruntime_draft_len, defaulting to0. Speculative metadata helpers move fromspeculative.pytometadata.py.LoraParamBuilderinitializesmodel_configtoNone.Key regression risks are component wiring, padding and graph flags, speculative metadata, warmup rank agreement and failure handling, and encoder-decoder cross-KV allocation and cleanup. The supplied material states that behavior changes are not intended. It provides no current review findings or complete test results. CI reports include
SUCCESS,UNSTABLE, andFAILUREoutcomes, but do not identify failed tests.QA Engineer Review
Unit tests changed across decoder inputs, metadata, graph handling, warmup, no-KV-cache inputs, and encoder-decoder handling. The waiver entry in
tests/integration/test_lists/waives.txtchanged totest_prepare_inputs_with_helix_parallelism; its skip reason remains unchanged. No test functions or IDs beyond that waiver rename are identified in the supplied summaries.Coverage includes padding and position layouts, dummy-request admission and cleanup, graph selection and fallback, speculative metadata, warmup rank agreement and OOM handling, and encoder-decoder cross-attention. The changed tests are under
tests/unittest/, so integration-list membership is not applicable. The live list search confirms the Helix test appears inwaives.txt; it found no matching entry fortest_kvcm2_integration.pyin CI or manual-QA lists. Coverage verdict: needs follow-up. No test execution results are supplied.Per-File QA Perspective
Source files
tensorrt_llm/_torch/attention/backends/sparse/dsa/metadata.py: Comment references change to the input preparer; no runtime change is reported.tensorrt_llm/_torch/models/modeling_multimodal_mixin.py: Comments identify the new input-preparation path; no runtime change is reported.tensorrt_llm/_torch/models/modeling_multimodal_utils.py: The sync-free contract comment references the new preparation methods; no runtime change is reported.tensorrt_llm/_torch/modules/mamba/mamba2_metadata.py: A comment identifies the new input-preparation path; no runtime change is reported.tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py: Comments refer to the new graph and input components; no runtime change is reported.tensorrt_llm/_torch/pyexecutor/engine/lora.py:model_confignow initializes toNone; verify its initialization and graph-manager replacement during resource rebuilds.tensorrt_llm/_torch/pyexecutor/engine/multimodal.py: A docstring references the new metadata component; no runtime change is reported.tensorrt_llm/_torch/pyexecutor/engine/runners/common.py: New helpers handle padding, graph eligibility, metadata updates, and model-input construction; verify padded and unpadded inputs.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/__init__.py:ExtraInputsCollectoris imported from its new module; package exports are reported unchanged.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/dummy_requests.py: New factory paths create and release warmup and graph-capture requests; verify admission limits and cleanup on allocation failures.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/graphs.py: New graph management handles selection, capture, replay, and cleanup; verify shape selection, promotion gates, and eager fallback.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/metadata.py: New metadata setup and update paths handle attention, speculation, and rank counts; verify draft-length and synchronization rules.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/speculative.py: Speculative helpers are removed from this module and relocated tometadata.py; verify imports and callers use the new location.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/warmup.py: New warmup orchestration coordinates ranks, shapes, backend selection, and recoverable failures; verify distributed agreement and OOM handling.tensorrt_llm/_torch/pyexecutor/engine/runners/encoder_decoder.py: New specialized components handle cross-attention, graph capture, and dummy requests; verify fast-path eligibility and cross-KV cleanup.tensorrt_llm/_torch/pyexecutor/engine/runners/interface.py:PreparedInputs.runtime_draft_lendefaults to0; verify callers accept the additional field.tensorrt_llm/_torch/pyexecutor/engine/runners/no_kv_cache.py: Shared helpers replace inline padding and input construction; verify no-KV-cache metadata and buffer behavior.tensorrt_llm/_torch/pyexecutor/engine/runners/decoder/runner.py: Runner responsibilities now delegate to the split components; verify forward, graph, warmup, and release paths preserve behavior.tensorrt_llm/_torch/pyexecutor/guided_decoder.py: A comment points to the new preprocessing location; no runtime change is reported.tensorrt_llm/_torch/pyexecutor/kv_cache/mamba_cache_manager.py: A docstring references the relocated draft-length mapping helper; implementation is reported unchanged.tensorrt_llm/_torch/pyexecutor/llm_request.py: Comments reference the new input-preparation methods; no runtime change is reported.tensorrt_llm/_torch/pyexecutor/py_executor.py: A comment references the new input-preparation path; no runtime change is reported in the supplied summary.tensorrt_llm/_torch/pyexecutor/py_executor_creator.py: The helper import now comes from the decoder inputs module; verify the import path.tensorrt_llm/_torch/pyexecutor/resource_manager.py: Comments reference the new input-preparation methods; no runtime change is reported.tensorrt_llm/_torch/route_capture.py: A comment identifies the new input-preparation path; no runtime change is reported.tensorrt_llm/_torch/speculative/dspark.py: A comment references the new dummy-request factory; no runtime change is reported.tensorrt_llm/_torch/speculative/interface.py: A field comment references the relocated greedy-sampling helper; no runtime change is reported.Test-code files
tests/unittest/_torch/attention/sparse/csa2/test_metadata.py: Exercises deferred metadata refresh throughDecoderInputPreparer; integration-list membership is not applicable.tests/unittest/_torch/executor/engine/test_common.py: Covers padded and unpadded tokens, position layouts, graph flags, and buffer updates; integration-list membership is not applicable.tests/unittest/_torch/executor/engine/test_decoder_speculative.py: Updates imports for relocated metadata helpers; no coverage change is reported. Integration-list membership is not applicable.tests/unittest/_torch/executor/engine/test_encoder_decoder.py: Covers specialized components, cross-KV cleanup and allocation failure, warmup ordering, and cross-attention; integration-list membership is not applicable.tests/unittest/_torch/executor/engine/test_no_kv_cache.py: Updates the patch target for the shared helper; integration-list membership is not applicable.tests/unittest/_torch/executor/engine/test_runners.py: Initializes the JIT warmup flag in a fixture; integration-list membership is not applicable.tests/unittest/_torch/executor/kv_cache/test_kvcm2_integration.py: Covers dummy-request creation for graph warmup; no matching CI or manual-QA list entry was found, and integration-list membership is not applicable to this unit-test path.tests/unittest/_torch/executor/test_context_only_warmup.py: Covers request bounds, admission failures, request phases, and graph selection; integration-list membership is not applicable.tests/unittest/_torch/executor/test_distributed_warmup_oom.py: Covers rank agreement, shape selection, and recovery or fatal errors; integration-list membership is not applicable.tests/unittest/_torch/executor/test_eager_workspace_engine.py: Covers workspace-reclaimer eligibility throughDecoderWarmup; integration-list membership is not applicable.tests/unittest/_torch/executor/test_gen_only_cached_tokens.py: Updates a test comment to identify the context-packing method; integration-list membership is not applicable.tests/unittest/_torch/executor/test_py_executor.py: Updates a comment about draft-token preparation; integration-list membership is not applicable.tests/unittest/_torch/executor/test_pytorch_model_engine.py: Covers split-component behavior, graph paths, metadata, and buffer ownership; integration-list membership is not applicable.tests/unittest/_torch/executor/test_pytorch_model_engine_warmup.py: Covers warmup ordering, tuning, fallback, and graph timing; integration-list membership is not applicable.tests/unittest/_torch/executor/test_remote_tail_adp_phase.py: Covers attention-DP and decode-rank-token helpers; integration-list membership is not applicable.tests/unittest/_torch/executor/test_token_budget_fallback.py: Updates comments about input preparation; integration-list membership is not applicable.tests/unittest/_torch/modeling/test_modeling_deepseekv41.py: Covers all-rank speculative token counts through the input preparer; integration-list membership is not applicable.tests/unittest/_torch/speculative/test_capture_sampling_params.py: Updates the import source for capture sampling parameters; integration-list membership is not applicable.Test-list file
tests/integration/test_lists/waives.txt: Renames the Helix-parallelism waiver entry and retains its skip reason. The updated test name is present in the waiver list.Description
#19896 moved the decoder code out of
model_engine.pyunchanged, leavingDecoderRunneras a single class that owns every phase. This PR splits it into components.DecoderRunnerkeeps construction, the public entry points and the forward path. Each phase becomes a component that owns its state and gets its dependencies through its constructor, without a reference back to the runner:InputBuffers;The runner builds its components through overridable factories.
EncoderDecoderRunnerstays a subclass and overrides them to return component subclasses:Execution paths that a model family cannot take are declared as capability flags on the runner.
Method bodies move unchanged apart from attribute paths. The few deliberate reshapes are:
runners/common.py, shared by the decoder and no-KV-cache runners;PreparedInputs.No behaviour change is intended.
The tests no longer patch or call private runner methods by name:
Test Coverage
tests/unittest/_torch/executor/test_pytorch_model_engine.pytests/unittest/_torch/executor/test_pytorch_model_engine_warmup.pytests/unittest/_torch/executor/test_context_only_warmup.pytests/unittest/_torch/executor/test_distributed_warmup_oom.pytests/unittest/_torch/executor/test_eager_workspace_engine.pytests/unittest/_torch/executor/test_remote_tail_adp_phase.pytests/unittest/_torch/executor/engine/test_encoder_decoder.pytests/unittest/_torch/executor/engine/test_common.pytests/unittest/_torch/executor/test_py_executor.pyPR 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.