Skip to content

[None][fix] Guard model_engine access in PyExecutor._handle_responses - #19559

Merged
brnguyen2 merged 1 commit into
NVIDIA:mainfrom
brnguyen2:fix/guard-model-engine-handle-responses
Sep 23, 2026
Merged

brnguyen2 merged 1 commit into
NVIDIA:mainfrom
brnguyen2:fix/guard-model-engine-handle-responses

Conversation

@brnguyen2

@brnguyen2 brnguyen2 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

_handle_responses now safely accesses model_engine.route_capture with nested getattr. This prevents AttributeError for minimal PyExecutor instances while preserving route attachment when available. The file also contains broad import-formatting changes with no stated behavior change.

QA Engineer Review

No test changes.

Per-File QA Perspective

  • tensorrt_llm/_torch/pyexecutor/py_executor.py: Verify response handling with and without model_engine, including completed requests with route capture enabled. Confirm route attachment remains unchanged for normal executors.

Description

Commit 5982425 (#18397, Router Replay) added a route_capture = getattr(self.model_engine, ...) lookup in PyExecutor._handle_responses. Unlike the other route_capture call sites in the same commit, this one does not guard the model_engine attribute itself. #19478 later merged unit tests that construct a minimal PyExecutor (via object.__new__) without a model_engine attribute, so main now deterministically fails these two unit tests:

  • unittest/_torch/disaggregation/test_disagg_coordinator_errors.py::test_refused_python_cancel_is_retried_and_settled_through_the_real_response_path
  • unittest/_torch/disaggregation/test_disagg_coordinator_errors.py::test_cancelling_part_of_a_saturated_receive_batch_settles_only_those_requests

with:

tensorrt_llm/_torch/pyexecutor/py_executor.py: in _handle_responses
    route_capture = getattr(self.model_engine, "route_capture", None)
E   AttributeError: 'PyExecutor' object has no attribute 'model_engine'

The fix mirrors the guarded pattern the same commit already uses elsewhere in this file: getattr(getattr(self, "model_engine", None), "route_capture", None).

Test Coverage

The two unit tests above (already in l0 CPU coverage) exercise this exact code path and fail on current main without this change.

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.

Minimal PyExecutor instances built by unit tests do not set
model_engine, so the unguarded self.model_engine lookup in
_handle_responses raises AttributeError. Guard it with the same
getattr pattern already used at the other route_capture call sites.

Signed-off-by: Brian Nguyen <[email protected]>
@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fab89496-2262-4de0-8643-8719c667d91c

📥 Commits

Reviewing files that changed from the base of the PR and between 3453341 and 4ba65ea.

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

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.


Walkthrough

_handle_responses now safely handles executor instances without model_engine while preserving route attachment when a capture object exists.

Changes

Response handling

Layer / File(s) Summary
Safe route capture lookup
tensorrt_llm/_torch/pyexecutor/py_executor.py
The handler tolerates a missing model_engine when it looks up route_capture. Existing route attachment remains unchanged when capture data exists.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: nv-xtf

Merge Risk: ⚪ Minimal · up to 4ba65

The response handler now tolerates minimal executors while preserving route capture when available.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix and names the affected PyExecutor behavior. It follows the required [None][fix] format.
Description check ✅ Passed The description explains the failure, root cause, solution, affected tests, and test coverage. It also includes the required checklist and marks the review complete.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75103 [ run ] triggered by Bot. Commit: 4ba65ea Link to invocation

@github-actions

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75103 [ run ] completed with state FAILURE. Commit: 4ba65ea
/LLM/main/L0_MergeRequest_PR pipeline #61856 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

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75146 [ run ] triggered by Bot. Commit: 4ba65ea Link to invocation

@brnguyen2

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "Urgent: unblocks L0 pre-merge breakage on main (two disagg-coordinator unit tests fail in CPU-Generic for every PR). Prior pipeline validated this commit: single-GPU run passed 190/190 including both affected tests; the only failure was an infra-level multi-GPU stage loss (SLURM job failure / offline nodes) with no product-code failures. The 4-line guard change is not exercised differently by multi-GPU stages."

@brnguyen2
brnguyen2 enabled auto-merge (squash) September 23, 2026 01:40
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75153 [ skip ] triggered by Bot. Commit: 4ba65ea Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75146 [ run ] completed with state ABORTED. Commit: 4ba65ea

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #75153 [ skip ] completed with state SUCCESS. Commit: 4ba65ea
Skipping testing for commit 4ba65ea

Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants