[TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler and sampler_type - #18223
Closed
zhaoyangwang-nvidia wants to merge 1 commit into
Closed
[TRTLLM-15405][refactor] BREAKING: Remove TRTLLMSampler and sampler_type#18223zhaoyangwang-nvidia wants to merge 1 commit into
zhaoyangwang-nvidia wants to merge 1 commit into
Conversation
zhaoyangwang-nvidia
force-pushed
the
remove-trtllm-sampler
branch
2 times, most recently
from
August 26, 2026 06:08
77e9079 to
95bcede
Compare
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
force-pushed
the
remove-trtllm-sampler
branch
from
August 26, 2026 06:25
95bcede to
201f048
Compare
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.
@coderabbitai summary
Description
JIRA: TRTLLM-15405
Removal plan
TRTLLMSampleris removed in two steps so that every user-visible change landsin one small review and the bulk deletion stays a pure dead-code change:
sampler_typeLLM API option, plus tests and docsStep 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/includesruntime/decodingLayerWorkspace.hwhileruntime/gptDecoder.cppanddecodingLayerWorkspace.hincludelayers/decodingParams.h, so deleting either side alone leaves the otheruncompilable.
This PR is step 1.
TorchSamplerbecomes the only sampling backend. This has been signposted for a while:sampler_typealready carries astatus="deprecated"marker and a "will be removed in release 1.4" notice, andTorchSamplerhas supported a superset ofTRTLLMSampler's features for several releases (the docs stated as much).autoalready resolved toTorchSampler, so the default path is unchanged.Removed: the
TRTLLMSamplerclass and itsSampleState*types,make_decoding_batch_input_output.py, and the helpers only it reached (get_decoding_mode(),update_sampler_max_seq_len()), plus the now-deadtrtllm_samplerfeature-conflict rules.API change. The
sampler_typeoption and itsSamplerTypeenum are removed outright. OnceTRTLLMSampleris gone,autoandTorchSamplerresolve 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.autowas the default, so code that never set it is unaffected; code that passedsampler_type=(includingsampler_type:in a YAML--extra_llm_api_optionsfile) must drop the line. Both consumers are simplified in step: the AutoDeploy shim constructsTorchSamplerdirectly instead of branching, andvalidate_feature_combination()drops itssampler_typeparameter along with thetorch_samplerfeature 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: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), andtest_llmapi_config_capture.py::test_collect_llm_api_config_captures_sampler_type_categorical(load_formatstill covers theUnion[str, Enum]telemetry path).test_beam_search.py,test_logits_logprobs.py,test_overlap_scheduler.py,_test_openai_chat.py,_test_openai_completions.pyandtest_e2e.py. Two guards intest_beam_search.pyhad 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 affectedwaives.txtandtest-db/l0_a30.ymlentries are updated, and thetest_e2e.pywrappers now filter on-k logit_bias_effectinstead 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 toTorchSampler— it exercises beam-slot reuse, which is not sampler-specific.Local verification:
pre-commitpasses 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-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.