Skip to content

[TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler and sampler_type - #18223

Closed
zhaoyangwang-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
zhaoyangwang-nvidia:remove-trtllm-sampler
Closed

[TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler and sampler_type#18223
zhaoyangwang-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
zhaoyangwang-nvidia:remove-trtllm-sampler

Conversation

@zhaoyangwang-nvidia

@zhaoyangwang-nvidia zhaoyangwang-nvidia commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

JIRA: TRTLLM-15405

Removal plan

TRTLLMSampler is removed in two steps so that every user-visible change lands
in one small review and the bulk deletion stays a pure dead-code change:

Step Scope Size
1 Python sampler + the sampler_type LLM API option, plus tests and docs 47 files, −1391
2 The C++ decoder stack that step 1 leaves unreachable 131 files, −34126

Step 1 carries all of the API risk and is independently correct: afterwards the
C++ decoder still builds, it simply has no caller. Step 2 then deletes it
without touching behaviour.

Step 2 is not split further because the subsystem is mutually recursive —
layers/ includes runtime/decodingLayerWorkspace.h while
runtime/gptDecoder.cpp and decodingLayerWorkspace.h include
layers/decodingParams.h, so deleting either side alone leaves the other
uncompilable.

This PR is step 1.

TorchSampler becomes the only sampling backend. This has been signposted for a while: sampler_type already carries a status="deprecated" marker and a "will be removed in release 1.4" notice, and TorchSampler has supported a superset of TRTLLMSampler's features for several releases (the docs stated as much). auto already resolved to TorchSampler, so the default path is unchanged.

Removed: the TRTLLMSampler class and its SampleState* types, make_decoding_batch_input_output.py, and the helpers only it reached (get_decoding_mode(), update_sampler_max_seq_len()), plus the now-dead trtllm_sampler feature-conflict rules.

API change. The sampler_type option and its SamplerType enum are removed outright. Once TRTLLMSampler is gone, auto and TorchSampler resolve to the same sampler, so the option no longer selects anything — keeping a single-valued knob would only be a way to get it wrong. auto was the default, so code that never set it is unaffected; code that passed sampler_type= (including sampler_type: in a YAML --extra_llm_api_options file) must drop the line. Both consumers are simplified in step: the AutoDeploy shim constructs TorchSampler directly instead of branching, and validate_feature_combination() drops its sampler_type parameter along with the torch_sampler feature flag, which fed no conflict rule. The telemetry allowlist, golden manifest, API-stability reference and docs are updated to match.

This PR touches no C++ at all, so the C++ build is unaffected; the decoder stack it orphans is deleted in step 2.

Test Coverage

Existing tests. Coverage specific to the removed sampler is deleted; everything else is re-pointed at TorchSampler:

  • Deleted: tests/unittest/_torch/sampler/test_trtllm_sampler.py, tests/unittest/auto_deploy/singlegpu/smoke/test_ad_trtllm_sampler.py, TestParameterValidation::test_logprobs_trtllm_sampler (asserted a C++-decoder-only error), and test_llmapi_config_capture.py::test_collect_llm_api_config_captures_sampler_type_categorical (load_format still covers the Union[str, Enum] telemetry path).
  • Sampler parametrization is dropped entirely (it now has a single value) across test_beam_search.py, test_logits_logprobs.py, test_overlap_scheduler.py, _test_openai_chat.py, _test_openai_completions.py and test_e2e.py. Two guards in test_beam_search.py had degenerated with the parameter (one skipped unconditionally, one never skipped) and are removed rather than left misleading. Test ids shift as a result, so the affected waives.txt and test-db/l0_a30.yml entries are updated, and the test_e2e.py wrappers now filter on -k logit_bias_effect instead of the removed -k torch_sampler, which would otherwise have matched nothing and silently run zero tests.
  • test_beam_search.py::test_beam_search_large_beam_width_regression (nvbugs/6242591) is kept and switched to TorchSampler — it exercises beam-slot reuse, which is not sampler-specific.

Local verification: pre-commit passes on all changed files.

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.

@zhaoyangwang-nvidia zhaoyangwang-nvidia added the api-breaking Accepted LLM API contract change that is backwards-incompatible label Aug 26, 2026
@zhaoyangwang-nvidia
zhaoyangwang-nvidia force-pushed the remove-trtllm-sampler branch 2 times, most recently from 77e9079 to 95bcede Compare August 26, 2026 06:08
TRTLLMSampler and the C++ decoder stack behind it are removed; TorchSampler
is now the only sampling backend. The sampler_type option has carried a
"will be removed in release 1.4" deprecation notice, and TorchSampler has
supported a superset of its features for several releases.

Removed on the Python side: the TRTLLMSampler class and its SampleState
types, make_decoding_batch_input_output.py, and the now-unreachable
get_decoding_mode()/update_sampler_max_seq_len() helpers.

Removed on the C++ side: cpp/tensorrt_llm/layers/, the runtime decoder stack
(gptDecoder, gptDecoderBatched, decoderState, decodingInput/Output,
decodingLayerWorkspace), createNewDecoderRequests, decoderBuffers,
medusaBuffers, eagleBuffers, explicitDraftTokensBuffers, decodingKernels,
beamSearchKernels,
the orphaned medusa/externalDraftTokens kernels, the dynamicDecodeOp and
gatherTreeOp torch ops, and the corresponding nanobind bindings and gtests.
gatherTreeOp's only caller was tensorrt_llm/runtime/generation.py, which was
removed along with the legacy TensorRT backend.

The sampler_type LLM API option is removed along with the SamplerType enum.
With TRTLLMSampler gone, "auto" and "TorchSampler" selected the same sampler,
so the option no longer chose anything; its deprecation notice already
announced removal. Both remaining consumers are simplified accordingly: the
AutoDeploy shim now constructs TorchSampler directly, and
validate_feature_combination() drops its sampler_type parameter and the
torch_sampler feature flag that fed no conflict rule.

The beam-width limits that beamSearchKernels.h exported (kMaxBeamWidth,
kMaxBeamWidthArrayLength) are request-admission bounds rather than kernel
parameters, so they move into executor::SamplingConfig next to the
checkBeamWidth()/checkBeamWidthArray() helpers that enforce them.

Signed-off-by: ZhaoyangWang <zhaoyangw@nvidia.com>
@zhaoyangwang-nvidia zhaoyangwang-nvidia changed the title [TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler [TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler and sampler_type Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-breaking Accepted LLM API contract change that is backwards-incompatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant