[None][fix] Fix latent mypy errors in sampler.py (no-any-return, comparison-overlap) - #17783
Conversation
…arison-overlap) Two pre-existing mypy errors surface on PRs whose build compiles the bindings, triggering the full mypy type check: - _meet_max_token_stop_criteria returned an Any-typed boolean expression (operands come from Any-typed C++ binding attributes) from a -> bool function [no-any-return]; wrap the return in bool(). - update_requests compared req.state to GENERATION_COMPLETE after an earlier 'continue' narrowed that literal away. The state is mutated at runtime by the intervening calls (process_draft_tokens -> _handle_stop_criteria -> finish_by), which mypy cannot track, so the comparison is valid; annotate with a precise type: ignore and comment [comparison-overlap]. Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan includes up to 12 reviews per rolling hour; 9 remain after this review. WalkthroughThe sampler now normalizes max-token stop-criteria results to ChangesSampler typing updates
Integration performance waivers
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR makes localized type-checking fixes without changing runtime behavior; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/bot run |
|
PR_Github #66566 [ run ] triggered by Bot. Commit: |
|
PR_Github #66566 [ run ] completed with state
|
|
/bot run |
|
PR_Github #66570 [ run ] triggered by Bot. Commit: |
|
PR_Github #66570 [ run ] completed with state
|
|
/bot run |
|
PR_Github #66574 [ run ] triggered by Bot. Commit: |
|
PR_Github #66574 [ run ] completed with state
|
|
/bot run |
PR NVIDIA#17609 de-enrolled a batch of perf/test_perf_sanity.py::test_e2e DeepSeek-V3.2 / Kimi-K2.5 cases from the test-db perf_sanity lists but left their entries in waives.txt. Those 18 entries now reference tests that exist in no L0 or QA list, so the "Check Test List" stage fails on every PR with "Non-existent test name in l0 or qa list found in waives.txt". Remove the orphaned entries. Their nvbug SKIPs are moot now that the tests no longer run. Verified: no perf_sanity waive references a non-existent list entry after this change; AST validation and the duplicate-waives check both pass. Signed-off-by: Brian Nguyen <brnguyen@nvidia.com> (cherry picked from commit c42fdcd)
|
/bot run |
|
PR_Github #66578 [ run ] triggered by Bot. Commit: |
|
PR_Github #66583 [ run ] triggered by Bot. Commit: |
|
/bot skip --comment "no functional change" |
|
PR_Github #66578 [ run ] completed with state |
|
PR_Github #66584 [ skip ] triggered by Bot. Commit: |
|
PR_Github #66586 [ skip ] triggered by Bot. Commit: |
|
PR_Github #66584 [ skip ] completed with state |
|
PR_Github #66583 [ run ] completed with state |
|
PR_Github #66586 [ skip ] completed with state |
…arison-overlap) (NVIDIA#17783) Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…arison-overlap) (NVIDIA#17783) Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…arison-overlap) (#17783) Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…arison-overlap) (#17783) Signed-off-by: Brian Nguyen <brnguyen@nvidia.com>
…x/cutedsl-skip-softmax-wiring
Description
Fixes two pre-existing mypy errors in
tensorrt_llm/_torch/pyexecutor/sampler/sampler.py. Both are latent onmainand only surface on PRs whose build compiles the bindings, whichtriggers the full mypy type check (
scripts/run_mypy.shprints"Compiled bindings detected — running full mypy type check"). They are
unrelated to any feature work.
1.
no-any-returnin_meet_max_token_stop_criteriaThe function is declared
-> boolbut returns(num_tokens - request.py_orig_prompt_len >= request.py_max_new_tokens) or (num_tokens >= max_seq_len).get_num_tokens(),py_orig_prompt_len, andpy_max_new_tokensallderive from
Any-typed C++ binding attributes, so mypy infers the wholeboolean expression as
Any. Wrapping the return inbool(...)gives thedeclared type without changing runtime behavior.
2.
comparison-overlapinupdate_requestsif req.state == LlmRequestState.GENERATION_COMPLETE:near the end of theper-request loop. An earlier
continueat the top of the same loop(
if req.state == LlmRequestState.GENERATION_COMPLETE: continue)flow-narrows
req.stateto a literal set that excludesGENERATION_COMPLETE, so mypy flags the later comparison as always-false.This branch is genuinely reachable at runtime: within the loop body
req.stateis mutated toGENERATION_COMPLETEby the intervening calls(
process_draft_tokens->_handle_stop_criteria->finish_by, and_handle_finish_reasons_impl), which mypy cannot track across methodboundaries. This is a mypy flow-narrowing limitation, not a too-narrow
annotation — the declared type of
statealready includesGENERATION_COMPLETE; there is no annotation to widen. I therefore addeda precise
# type: ignore[comparison-overlap]with a comment explainingwhy the comparison is valid, rather than deleting the (live) branch.
Test Coverage
No behavior change. The
bool(...)wrap is value-preserving and thetype: ignorehas no runtime effect.Verification
The full mypy check needs compiled bindings plus torch, which are not
available in a fresh worktree on the head node, so I could NOT run the
full check and am not claiming mypy passes. The rest of the pre-commit
suite (ruff, ruff-format, codespell, DCO, etc.) passed on the changed
file with no reformatting. Both fixes are justified above by the operand
types and the control-flow reasoning.
Dev Engineer Review
sampler.py.bool(...)conversion for_meet_max_token_stop_criteria.# type: ignore[comparison-overlap]with an explanatory comment inupdate_requests.QA Engineer Review
tests/integration/test_lists/waives.txt.