Skip to content

[TRTLLM-14155][fix] Revert host-side greedy stop checks from #15920 - #16163

Merged
chzblych merged 1 commit into
NVIDIA:mainfrom
mingyangHao:codex/revert-pr15920
Jul 9, 2026
Merged

[TRTLLM-14155][fix] Revert host-side greedy stop checks from #15920#16163
chzblych merged 1 commit into
NVIDIA:mainfrom
mingyangHao:codex/revert-pr15920

Conversation

@mingyangHao

@mingyangHao mingyangHao commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This reverts commit 4f1c3cd.

Summary by CodeRabbit

  • Bug Fixes
    • Improved sampling behavior consistency across requests, especially for beam and greedy paths.
    • Finish-reason handling is now applied more reliably during token generation, reducing edge-case differences.
    • Removed a special-case path that could lead to inconsistent stopping behavior in some scenarios.

Description

Test Coverage

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.

@mingyangHao
mingyangHao requested a review from a team as a code owner July 9, 2026 03:31
@mingyangHao
mingyangHao requested a review from joyang-nv July 9, 2026 03:31
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change removes the host stop-criteria fast path from TorchSampler. SampleStateTorch replaces its use_host_stop_criteria field with beam_history_builders. _process_requests and sample_async now always compute and propagate seq_lens_host/seq_lens_cuda, and device-side finish-reason handling always runs. Associated unit tests for the removed fast path are deleted.

Changes

Host stop-criteria fast-path removal

Layer / File(s) Summary
Dataclass and helper changes
tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
SampleStateTorch replaces use_host_stop_criteria with beam_history_builders; the _can_use_host_stop_criteria helper is removed.
update_requests always uses process_draft_tokens
tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
Single-beam branch always calls process_draft_tokens(...) instead of conditionally short-circuiting on host stop criteria.
_process_requests unconditional seq_lens computation
tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
_process_requests always computes and returns seq_lens_host/seq_lens_cuda, simplifies destination indexing in the fast greedy path, and updates return tuple ordering for both fast and non-fast paths.
sample_async unpacking and finish-reason handling
tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
sample_async updates unpacking of returned values, always runs device-side finish-reason handling, and SampleStateTorch construction reflects the new field.
Remove host stop-criteria fast-path tests
tests/unittest/_torch/sampler/test_torch_sampler.py
Deletes tests validating the fast path and its fallback behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: ziyixiong-nv, dongxuy04, hnover-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only states it reverts a commit and omits the required issue/solution and test coverage sections. Add a short Description explaining what changed and why, list relevant Test Coverage, and ensure the PR Checklist is complete.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change as reverting host-side greedy stop checks.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/sampler/sampler.py`:
- Line 3787: The `sample_async` unpacking includes `seq_lens_host`, but that
symbol is never used afterward and triggers RUF059. Update the unpacking near
`sample_async` so only the needed values are assigned, or replace the unused
slot with a throwaway placeholder, while keeping the existing `seq_lens_cuda`
flow into `write_finish_reasons` and `_update_original_tokens` intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 17372634-8982-4a48-86a9-579f058c810d

📥 Commits

Reviewing files that changed from the base of the PR and between 60583d2 and cc19fe7.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
  • tests/unittest/_torch/sampler/test_torch_sampler.py
💤 Files with no reviewable changes (1)
  • tests/unittest/_torch/sampler/test_torch_sampler.py

Comment thread tensorrt_llm/_torch/pyexecutor/sampler/sampler.py
@mingyangHao

Copy link
Copy Markdown
Collaborator Author

/bot run --add-multi-gpu-test --disable-fail-fast

@mingyangHao mingyangHao changed the title [None][fix] Revert host-side greedy stop checks from #15920 [TRTLLM-14155][fix] Revert host-side greedy stop checks from #15920 Jul 9, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58364 [ run ] triggered by Bot. Commit: 8efd819 Link to invocation

This reverts commit 4f1c3cd.

Signed-off-by: Mingyang Hao <200044211+mingyangHao@users.noreply.github.com>
@mingyangHao
mingyangHao force-pushed the codex/revert-pr15920 branch 2 times, most recently from d0a65db to 6fcfd81 Compare July 9, 2026 06:01
@chzblych

chzblych commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot skip --comment "Bring TOT main back to normal"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58390 [ skip ] triggered by Bot. Commit: 6fcfd81 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58364 [ run ] completed with state ABORTED. Commit: 8efd819

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58390 [ skip ] completed with state SUCCESS. Commit: 6fcfd81
Skipping testing for commit 6fcfd81

Link to invocation

@chzblych
chzblych merged commit 9a8ec05 into NVIDIA:main Jul 9, 2026
7 checks passed
mingyangHao added a commit to mingyangHao/TensorRT-LLM that referenced this pull request Jul 9, 2026
Reland the host-side greedy stop-criteria fast path from NVIDIA#15920 after its temporary revert in NVIDIA#16163.

Signed-off-by: Mingyang Hao <200044211+mingyangHao@users.noreply.github.com>
trtllm-agent added a commit to tensorrt-cicd/TensorRT-LLM that referenced this pull request Jul 20, 2026
The TorchSampler IndexError described in nvbug 6435097 was introduced by
PR NVIDIA#15920 ("Move greedy stop checks to host") and cleanly reverted by
PR NVIDIA#16163 (commit 9a8ec05). PR NVIDIA#16163 is already present at HEAD, so
the underlying code bug is fixed.

The waiver at nvbugs/6427411 for
test_ctx_pp_gen_tp_asymmetric[GSM8K-gen_tp=1-ctx_pp=2] was added by
PRs NVIDIA#16103 / NVIDIA#16105 / NVIDIA#16127 before the revert landed and was not
cleaned up afterward.

Verified locally on this HEAD (e523b43):
  pytest tests/integration/defs/accuracy/test_disaggregated_serving.py::\
    TestLlama3_1_8BInstruct::test_ctx_pp_gen_tp_asymmetric[GSM8K-gen_tp=1-ctx_pp=2]
  -> PASSED, GSM8K accuracy = 73.465 (threshold 70.997).

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
trtllm-agent added a commit to tensorrt-cicd/TensorRT-LLM that referenced this pull request Jul 21, 2026
The TorchSampler IndexError described in nvbug 6435097 was introduced by
PR NVIDIA#15920 ("Move greedy stop checks to host") and cleanly reverted by
PR NVIDIA#16163 (commit 9a8ec05). PR NVIDIA#16163 is already present at HEAD, so
the underlying code bug is fixed.

The waiver at nvbugs/6427411 for
test_ctx_pp_gen_tp_asymmetric[GSM8K-gen_tp=1-ctx_pp=2] was added by
PRs NVIDIA#16103 / NVIDIA#16105 / NVIDIA#16127 before the revert landed and was not
cleaned up afterward.

Verified locally on this HEAD (e523b43):
  pytest tests/integration/defs/accuracy/test_disaggregated_serving.py::\
    TestLlama3_1_8BInstruct::test_ctx_pp_gen_tp_asymmetric[GSM8K-gen_tp=1-ctx_pp=2]
  -> PASSED, GSM8K accuracy = 73.465 (threshold 70.997).

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants