[https://nvbugs/5845901][fix] Fix cancelled disagg requests stuck in gen server - #11695
Conversation
6ceb17d to
bf706eb
Compare
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
|
PR_Github #36701 [ run ] triggered by Bot. Commit: |
There was a problem hiding this comment.
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 | 🟠 MajorSpurious warnings and missing resource cleanup when calling
end_transferwith a bare int.1. False-positive log warnings (noise)
canceled_req_ids_setcontains every canceled ID, including requests that were still in the waiting queue (already removed bywaiting_queue.remove_by_idson line 3110). Those requests were never admitted to_request_transfer_metadata, soend_transfer(request_id)hits theKeyErrorguard on line 231 and emits alogger.warningfor 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=FalseWhen
end_transfercompletes (counter → 0) via theintpath, it skips theisinstance(request, LlmRequest)state-update branch and, critically, it never calls_terminate_request. The normal path through_end_transfer_and_maybe_terminatealways calls_terminate_requestafterend_transferreturnsTrue, which runsresource_manager.free_resources(request)andresult_wait_queues.pop(request_id).
- When
should_store_blocks=True, KV blocks are unpinned byend_transferitself, butresult_wait_queuesis still leaked.- When
should_store_blocks=False(AsyncTransferManageris constructed withshould_store_blocks=Falsewhenenable_partial_reuse_for_disaggisFalse), KV cache blocks are not managed by AsyncTransferManager at all. They are owned by theKvCacheManagerand must be freed viaresource_manager.free_resources. Skipping_terminate_requestin that case leaves those blocks permanently allocated.Because the
LlmRequestobject is reachable fromrequests_in_transfer[request_id], the fix is to re-use_end_transfer_and_maybe_terminatedirectly:🛠️ 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.
…transmission state Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
bf706eb to
76c024f
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #36710 [ run ] triggered by Bot. Commit: |
|
PR_Github #36710 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #36808 [ run ] triggered by Bot. Commit: |
|
PR_Github #36808 [ run ] completed with state |
…gen server (NVIDIA#11695) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
…gen server (NVIDIA#11695) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
…gen server (NVIDIA#11695) Signed-off-by: Iman Tabrizian <10105175+tabrizian@users.noreply.github.com>
@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 thestage-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.