Skip to content

[https://nvbugs/5845901][fix] Fix cancelled disagg requests stuck in gen server - #11695

Merged
Tabrizian merged 1 commit into
NVIDIA:mainfrom
Tabrizian:user/imant/nvbugs/5845901
Feb 25, 2026
Merged

[https://nvbugs/5845901][fix] Fix cancelled disagg requests stuck in gen server#11695
Tabrizian merged 1 commit into
NVIDIA:mainfrom
Tabrizian:user/imant/nvbugs/5845901

Conversation

@Tabrizian

@Tabrizian Tabrizian commented Feb 24, 2026

Copy link
Copy Markdown
Member

@coderabbitai summary

Description

The cancelled generation requests may get stuck if they are cancelled after they are scheduled (after the first iteration is completed before the second iteration)

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)

  • 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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@Tabrizian
Tabrizian requested a review from a team as a code owner February 24, 2026 23:50
@Tabrizian
Tabrizian force-pushed the user/imant/nvbugs/5845901 branch from 6ceb17d to bf706eb Compare February 24, 2026 23:50
@Tabrizian

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The end_transfer method signature was modified to accept either a LlmRequest object or an integer request ID. Internal lookups, removals, and error handling were updated to support both input types, with request ID resolution and type-guarded logic adjustments throughout related methods.

Changes

Cohort / File(s) Summary
Request Transfer Management
tensorrt_llm/_torch/pyexecutor/py_executor.py
Modified end_transfer to accept LlmRequest | int, resolving numeric IDs to request identifiers and updating dictionary operations accordingly. Enhanced _handle_canceled_requests and _handle_responses with type-aware logic and adjusted completion conditions for generation requests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is incomplete and does not follow the template. The Description section only contains one sentence without detailed explanation, and the Test Coverage section is entirely empty. Fill out the Description section with a thorough explanation of the issue and solution, and provide a clear list of relevant test cases that safeguard the changes in the PR.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required template with NVBugs ID and [fix] type, and clearly summarizes the main change: fixing cancelled disagg requests stuck in gen server.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #36701 [ run ] triggered by Bot. Commit: bf706eb Link to invocation

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tensorrt_llm/_torch/pyexecutor/py_executor.py (1)

1126-1130: ⚠️ Potential issue | 🟠 Major

Spurious warnings and missing resource cleanup when calling end_transfer with a bare int.

1. False-positive log warnings (noise)

canceled_req_ids_set contains every canceled ID, including requests that were still in the waiting queue (already removed by waiting_queue.remove_by_ids on line 3110). Those requests were never admitted to _request_transfer_metadata, so end_transfer(request_id) hits the KeyError guard on line 231 and emits a logger.warning for every such request. The fix is to guard the call with an explicit membership check:

requests_in_transfer = self.async_transfer_manager.requests_in_transfer()
for request_id in canceled_req_ids_set:
    if request_id not in active_request_ids_set and request_id in requests_in_transfer:
        self.async_transfer_manager.end_transfer(request_id)

2. Incomplete resource cleanup when should_store_blocks=False

When end_transfer completes (counter → 0) via the int path, it skips the isinstance(request, LlmRequest) state-update branch and, critically, it never calls _terminate_request. The normal path through _end_transfer_and_maybe_terminate always calls _terminate_request after end_transfer returns True, which runs resource_manager.free_resources(request) and result_wait_queues.pop(request_id).

  • When should_store_blocks=True, KV blocks are unpinned by end_transfer itself, but result_wait_queues is still leaked.
  • When should_store_blocks=False (AsyncTransferManager is constructed with should_store_blocks=False when enable_partial_reuse_for_disagg is False), KV cache blocks are not managed by AsyncTransferManager at all. They are owned by the KvCacheManager and must be freed via resource_manager.free_resources. Skipping _terminate_request in that case leaves those blocks permanently allocated.

Because the LlmRequest object is reachable from requests_in_transfer[request_id], the fix is to re-use _end_transfer_and_maybe_terminate directly:

🛠️ Proposed fix
-        active_request_ids_set = set(
-            [request.py_request_id for request in self.active_requests])
-        for request_id in canceled_req_ids_set:
-            if request_id not in active_request_ids_set:
-                self.async_transfer_manager.end_transfer(request_id)
+        active_request_ids_set = set(
+            request.py_request_id for request in self.active_requests)
+        requests_in_transfer = self.async_transfer_manager.requests_in_transfer()
+        for request_id in canceled_req_ids_set:
+            if request_id not in active_request_ids_set and request_id in requests_in_transfer:
+                self._end_transfer_and_maybe_terminate(
+                    requests_in_transfer[request_id])
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tensorrt_llm/_torch/pyexecutor/py_executor.py` around lines 1126 - 1130, The
loop that calls async_transfer_manager.end_transfer for canceled_req_ids_set is
producing spurious warnings and leaking resources: first, before calling
end_transfer(request_id) check membership in the active transfer set returned by
self.async_transfer_manager.requests_in_transfer() (e.g., if request_id not in
active_request_ids_set and request_id in requests_in_transfer: then call
end_transfer) to avoid KeyError-driven logger.warning noise; second, when
end_transfer is invoked via the bare-int path it can skip LlmRequest state
updates and never call _terminate_request, leaking result_wait_queues and
allocated KV blocks, so replace direct end_transfer(...) calls for those
int-path completions with a call to
_end_transfer_and_maybe_terminate(request_id) (which will call
_terminate_request and thereby resource_manager.free_resources and
result_wait_queues.pop) so cleanup runs regardless of should_store_blocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/py_executor.py`:
- Line 233: The function annotated with "-> bool" that currently ends with a
bare "return" should return an explicit boolean; replace the bare "return" with
"return False" to match the declared return type and satisfy type-checkers
(update the return in the function containing the bare "return" at the end of
its body so callers receive False instead of None).

---

Outside diff comments:
In `@tensorrt_llm/_torch/pyexecutor/py_executor.py`:
- Around line 1126-1130: The loop that calls async_transfer_manager.end_transfer
for canceled_req_ids_set is producing spurious warnings and leaking resources:
first, before calling end_transfer(request_id) check membership in the active
transfer set returned by self.async_transfer_manager.requests_in_transfer()
(e.g., if request_id not in active_request_ids_set and request_id in
requests_in_transfer: then call end_transfer) to avoid KeyError-driven
logger.warning noise; second, when end_transfer is invoked via the bare-int path
it can skip LlmRequest state updates and never call _terminate_request, leaking
result_wait_queues and allocated KV blocks, so replace direct end_transfer(...)
calls for those int-path completions with a call to
_end_transfer_and_maybe_terminate(request_id) (which will call
_terminate_request and thereby resource_manager.free_resources and
result_wait_queues.pop) so cleanup runs regardless of should_store_blocks.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab8d7cb and bf706eb.

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

Comment thread tensorrt_llm/_torch/pyexecutor/py_executor.py
…transmission state

Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
@Tabrizian
Tabrizian force-pushed the user/imant/nvbugs/5845901 branch from bf706eb to 76c024f Compare February 25, 2026 00:31
@Tabrizian

Copy link
Copy Markdown
Member Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #36710 [ run ] triggered by Bot. Commit: 76c024f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #36710 [ run ] completed with state SUCCESS. Commit: 76c024f
/LLM/main/L0_MergeRequest_PR pipeline #28427 completed with status: 'FAILURE'

⚠️ 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

Link to invocation

@pcastonguay

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #36808 [ run ] triggered by Bot. Commit: 76c024f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #36808 [ run ] completed with state SUCCESS. Commit: 76c024f
/LLM/main/L0_MergeRequest_PR pipeline #28501 completed with status: 'SUCCESS'

Link to invocation

@Tabrizian
Tabrizian merged commit 56001ab into NVIDIA:main Feb 25, 2026
8 of 9 checks passed
pcastonguay pushed a commit to pcastonguay/TensorRT-LLM that referenced this pull request Feb 27, 2026
…gen server (NVIDIA#11695)

Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
dominicshanshan pushed a commit to dominicshanshan/TensorRT-LLM that referenced this pull request Mar 9, 2026
…gen server (NVIDIA#11695)

Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
tianyuz-nv pushed a commit to wanqian-nv/TensorRT-LLM that referenced this pull request Mar 19, 2026
…gen server (NVIDIA#11695)

Signed-off-by: Iman Tabrizian <10105175+tabrizian@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