Skip to content

[None][fix] fix mypy error in sampler_strategy.py - #17638

Closed
weiminwang-nv wants to merge 1 commit into
NVIDIA:mainfrom
weiminwang-nv:user/weimin/fix-mypy
Closed

[None][fix] fix mypy error in sampler_strategy.py#17638
weiminwang-nv wants to merge 1 commit into
NVIDIA:mainfrom
weiminwang-nv:user/weimin/fix-mypy

Conversation

@weiminwang-nv

@weiminwang-nv weiminwang-nv commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaced two redundant mypy casts with direct BeamSearch.row_stride access.
  • Updated both direct and grouped beam-search sampling paths.
  • No public API or declaration changes.
  • Resolves the mypy errors reported by bash scripts/run_mypy.sh.

Dev Engineer Review

  • The changes are limited to redundant type casts.
  • Direct attribute access matches the BeamSearch type and preserves behavior.
  • No performance, error-handling, configuration, or API regressions are expected.
  • No test-list or configuration files changed.

QA Engineer Review

No test changes.

Description

Fix bash scripts/run_mypy.sh error after #17560 is merged:

tensorrt_llm/_torch/pyexecutor/sampler/sampler_strategy.py:354:  error: Redundant cast to "int"  [redundant-cast]
tensorrt_llm/_torch/pyexecutor/sampler/sampler_strategy.py:1344: error: Redundant cast to "BeamSearch"  [redundant-cast]
Found 2 errors in 1 file (checked 14 source files)

Example build

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.

Signed-off-by: Weimin Wang <301118019+weiminwang-nv@users.noreply.github.com>
@weiminwang-nv

Copy link
Copy Markdown
Contributor Author

/bot run

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 802ae73b-2b13-4d2f-9ea7-3048c34f4332

📥 Commits

Reviewing files that changed from the base of the PR and between 30cc13f and a5ccea7.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/sampler/sampler_strategy.py

Walkthrough

Beam-search direct and grouped sampling paths now access row_stride directly from the typed BeamSearch strategy.

Changes

Beam-search sampling

Layer / File(s) Summary
Typed row stride access
tensorrt_llm/_torch/pyexecutor/sampler/sampler_strategy.py
Direct sampling and grouped row sizing use BeamSearch.row_stride without redundant int casts.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Mergeability Score: ⚪ Minimal · up to a5cce

This is a narrowly scoped type-checking cleanup with no indicated runtime behavior change or actionable merge-blocking risk; it is merge-ready after normal checks and review.

Suggested reviewers: bowenfu, brnguyen2, chzblych, juney-nvidia, litaotju

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 follows the repository format and clearly states that it fixes a mypy error in sampler_strategy.py.
Description check ✅ Passed The description explains the issue and affected errors, but it does not list specific test coverage; the remaining template sections are present and reviewed.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65893 [ run ] triggered by Bot. Commit: a5ccea7 Link to invocation

@weiminwang-nv
weiminwang-nv enabled auto-merge (squash) August 13, 2026 10:47
rows_per_request = beam_width_in
if strategies and strategies[0][0] == "beam_search":
rows_per_request = cast(BeamSearch, strategies[0]).row_stride
rows_per_request = strategies[0].row_stride

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.

#17601 already provides the complete typed-pattern fix across this function, while #17637 carries the alternative suppression. Could this PR be closed or rebased after one approach lands instead of adding a third, partial implementation?

auto-merge was automatically disabled August 13, 2026 12:09

Pull request was closed

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #65893 [ run ] completed with state SUCCESS. Commit: a5ccea7
/LLM/main/L0_MergeRequest_PR pipeline #53585 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

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