Skip to content

[https://nvbugs/6104831][fix] Enforce request and buffer index lifecycle integrity - #14768

Merged
chienchunhung merged 10 commits into
NVIDIA:mainfrom
chienchunhung:nvbug6104831-tier-always-on-verify
Jun 3, 2026
Merged

[https://nvbugs/6104831][fix] Enforce request and buffer index lifecycle integrity#14768
chienchunhung merged 10 commits into
NVIDIA:mainfrom
chienchunhung:nvbug6104831-tier-always-on-verify

Conversation

@chienchunhung

@chienchunhung chienchunhung commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR is a strict subset of PR #13713 — same files, fewer changes — that carries only the components which (a) fix concrete pre-existing bugs and (b) are safe to land independently of the in-flight cancellation surface.

The goal is a low-risk increment that reviewers of PR #13713 can clear quickly: the included components are byte-equivalent ports of code already reviewed there; the deltas to audit are the exclusion decisions.

Relationship with PR #13713

This PR carries only the changes from PR #13713 that fix concrete pre-existing bugs (LlmRequest lifetime, buffer-slot leak on exception, NIXL agent lifetime) plus the observe-only timeout WARN. Everything in PR #13713 that exists to support the in-flight cancellation surface — both the surface itself and the always-on auxiliaries that the cancel-throw retry pattern depends on — is left out.

In-flight cancellation is default OFF in PR #13713. With that surface dormant, this PR and PR #13713 are conceptually the same bug-fix landing. The cancellation surface, and the auxiliaries needed to support it, are deferred to a follow-up.

What this PR fixes

Component Issue addressed
shared_ptr<LlmRequest> in async transfer ownership LlmRequest use-after-free: the async worker can outlive the request's scheduling lifetime; the raw pointer in the futures vector dereferences freed memory.
BufferIndexHolder RAII Buffer-slot leak on formatter exception paths (transient I/O error, peer disconnect, allocation failure) — each leak permanently reduces pool capacity until it exhausts.
NIXL nb::keep_alive<0, 1>() NIXL agent UAF: the agent can be torn down (executor recycle, shutdown) while a pending TransferStatus still references it.
Observe-only timeout WARN + dedup Wedged disagg KV transfers are silent today — no operator-visible signal identifying which request is stuck or for how long. Diagnostic, not a bug fix.

Mitigates NVBug 6104831 (and adjacent reports 6043291, 6162328). The three failure modes above are the cleanup-path bugs behind the customer-reported wedges, crashes, and silent corruption in long-running disaggregated deployments — they fire under client-side cancellations + load on main today, regardless of whether the in-flight cancellation feature is on. Merging this PR resolves those NVBugs without behavioral change for healthy traffic.

The in-flight cancellation feature itself is default OFF in PR #13713 and not in current production use; redesigning it (per-rank dedup → cross-rank-consistent primitive, retry semantics) is deferred to a follow-up and is not on the critical path for this reliability fix.

Test coverage

Two unit-test files:

  • cpp/tests/unit_tests/batch_manager/bufferIndexHolderTest.cpp — 10 parametrized test cases × 2 sides (send / recv) = 20 test instantiations. Uses a test-only ObservableTransBufferManager subclass that exposes the protected concurrence counter. Covers default-construct, nullopt-index, RAII release on scope exit, explicit release() + idempotency, detach() semantics, move-construct + move-assign ownership transfer, and exception-unwind release.
  • tests/unittest/others/test_kv_cache_transceiver.py — adds test_async_transfer_keeps_llm_request_alive[sender] / [receiver]. Uses a Python weakref.ref observer on the LlmRequest to verify that after the external Python reference is dropped, the C++ shared_ptr in mSenderFutures / mRequesterFutures keeps the wrapper alive. Would catch a regression where the futures vector reverted to a raw pointer.

Follow-up

In-flight cancellation needs more careful design and is deferred to a follow-up PR on top of this baseline.

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.

…exists

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
…ctx-side checkContextTransferStatus

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
…cle integrity.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung requested review from a team as code owners May 30, 2026 00:35
@chienchunhung chienchunhung changed the title [https://nvbugs/6104831][fix] Tier-1 always-on baseline (A1+A2+A4+A7+A8+A9+A10) [https://nvbugs/6104831][fix] Enforce request and buffer index lifecycle integrity May 30, 2026
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR migrates the cache transceiver request methods from raw pointer arguments to std::shared_ptr<LlmRequest> for better lifetime management, adds observe-only KV cache transfer timeout warnings, introduces a buffer holder RAII utility, and fixes rank-asymmetric deadlock risks in disaggregated serving.

Changes

Cache Transceiver and Disaggregated Safety

Layer / File(s) Summary
Cache Transceiver Interface Contract
cpp/include/tensorrt_llm/batch_manager/cacheTransceiver.h
BaseCacheTransceiver and CacheTransceiver virtual/override methods (respondAndSendAsync, requestAndReceiveSync, requestAndReceiveAsync, cancelRequest) change from LlmRequest* to std::shared_ptr<LlmRequest>. Internal mSenderFutures and mRequesterFutures containers updated to store shared pointers alongside futures to maintain request lifetime through async operations.
Cache Transceiver Implementation
cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp
Method bodies for respondAndSendAsync, requestAndReceiveSync, requestAndReceiveAsync, and cancelRequest adapted to accept shared pointers and move them into future containers while preserving request state access for completion/error paths.
KV Cache Transfer Timeout Monitoring
cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp
Both context and generation transfer status checks gain observe-only deadline mechanism (kvTransferTimeoutMs config). Deduplicated per-request WARN logging emitted when elapsed time exceeds budget; timeout entries erased on completion/error to allow re-warning on re-enqueue.
Call Sites and Binding Updates
cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp, cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp, cpp/tensorrt_llm/executor/cache_transmission/nixl_utils/agentBindings.cpp
trtGptModelInflightBatching passes shared pointers directly to respondAndSendAsync and receive methods. Nanobind PyCacheTransceiver overrides and BaseTransferAgent/NixlTransferAgent bindings updated with new shared pointer signatures and keep_alive<0, 1>() lifetime policies.
Buffer Index Holder RAII Utility
cpp/tensorrt_llm/batch_manager/baseTransBuffer.h, cpp/tensorrt_llm/batch_manager/baseTransBuffer.cpp
Move-only BufferIndexHolder class added to own and auto-release buffer slots from BaseTransBufferManager, with exception-safe out-of-line release() and detach() for responsibility transfer.
Disaggregated Cache Transfer Deadlock Prevention
tensorrt_llm/_torch/pyexecutor/py_executor.py
Python executor's context and generation cache transfer status checks compute rank-local at_least_num and unconditionally invoke collective operations, removing rank-asymmetric branching that could cause ABBA deadlocks with downstream gatherRequestIds collectives.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested reviewers

  • Shixiaowei02
  • pcastonguay
  • chuangz0
  • joyang-nv
  • nv-guomingz
  • syuoni
🚥 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 PR title '[https://nvbugs/6104831][fix] Enforce request and buffer index lifecycle integrity' is specific and directly relates to the primary changes, which focus on request ownership using shared pointers and buffer index management via the new BufferIndexHolder RAII class.
Description check ✅ Passed The PR description is comprehensive and well-structured. It explains the relationship with PR #13713, clearly lists what is fixed (with a detailed table), provides test coverage details, and includes a checklist with all items addressed.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp`:
- Around line 555-565: The timeout logging is computed using now - start before
verifying the transfer future completed, causing polling delay to be reported as
a timeout; update the polling/inspection logic (the loop that reads the transfer
future and emits WARNs) so you first check the transfer's completion/readiness
(e.g., future::wait_for(0) or equivalent) and skip timeout calculation/logging
if the future is already ready, then only compute elapsed = now - start and
consult kvTransferTimeoutMs and mTimedOutSenderIds when the transfer remains
incomplete; apply the same fix to the other similar blocks referenced around the
622-640 and 808-834 regions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8433b8e6-f940-404e-99bb-f9f6e4f6d3ae

📥 Commits

Reviewing files that changed from the base of the PR and between 74d7c3a and c06e70c.

📒 Files selected for processing (8)
  • cpp/include/tensorrt_llm/batch_manager/cacheTransceiver.h
  • cpp/tensorrt_llm/batch_manager/baseTransBuffer.cpp
  • cpp/tensorrt_llm/batch_manager/baseTransBuffer.h
  • cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp
  • cpp/tensorrt_llm/batch_manager/trtGptModelInflightBatching.cpp
  • cpp/tensorrt_llm/executor/cache_transmission/nixl_utils/agentBindings.cpp
  • cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp
  • tensorrt_llm/_torch/pyexecutor/py_executor.py

Comment thread cpp/tensorrt_llm/batch_manager/cacheTransceiver.cpp Outdated
@chienchunhung
chienchunhung marked this pull request as draft May 30, 2026 00:48
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
…ve entry

Restores the pre-A9/A10 behavior in _check_disagg_gen_transfer_status,
_prepare_disagg_gen_init, _executor_loop_pp, and _executor_loop to
match upstream/main. Reduces this PR's delta vs main and isolates the
rank-symmetric collective-entry changes for separate verification.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51140 [ run ] triggered by Bot. Commit: 5dfa4e9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51140 [ run ] completed with state SUCCESS. Commit: 5dfa4e9
/LLM/main/L0_MergeRequest_PR pipeline #40576 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51196 [ run ] triggered by Bot. Commit: 5dfa4e9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51196 [ run ] completed with state FAILURE. Commit: 5dfa4e9
/LLM/main/L0_MergeRequest_PR pipeline #40624 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51226 [ run ] triggered by Bot. Commit: 5dfa4e9 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51226 [ run ] completed with state SUCCESS. Commit: 5dfa4e9
/LLM/main/L0_MergeRequest_PR pipeline #40649 completed with status: 'SUCCESS'

CI Report

Link to invocation

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51237 [ run ] triggered by Bot. Commit: 3e879f5 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51237 [ run ] completed with state FAILURE. Commit: 3e879f5
/LLM/main/L0_MergeRequest_PR pipeline #40660 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

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
Comment thread cpp/include/tensorrt_llm/batch_manager/cacheTransceiver.h
Comment thread cpp/tensorrt_llm/batch_manager/baseTransBuffer.h
@pcastonguay

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51629 [ run ] triggered by Bot. Commit: 21e4890 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51629 [ run ] completed with state SUCCESS. Commit: 21e4890
/LLM/main/L0_MergeRequest_PR pipeline #41014 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51696 [ run ] triggered by Bot. Commit: 21e4890 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51696 [ run ] completed with state SUCCESS. Commit: 21e4890
/LLM/main/L0_MergeRequest_PR pipeline #41074 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51752 [ run ] triggered by Bot. Commit: 21e4890 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51752 [ run ] completed with state SUCCESS. Commit: 21e4890
/LLM/main/L0_MergeRequest_PR pipeline #41125 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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

PR#14916 (a cloned version of this PR + rebasing to the latest main) passed the targets tests that failed in this PR, confirming the code changes rebasing to the latest main should pas those tests.

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot help

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

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) --high-priority]

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. Supports wildcard * for pattern matching (e.g., "*PerfSanity*" matches all stages containing PerfSanity). Examples: "A10-PyTorch-1, xxx", "PerfSanity". 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. Supports wildcard * for pattern matching. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx", --extra-stage "Post-Merge".

--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.

--high-priority (OPTIONAL) : Run the pipeline with high priority. This option is restricted to authorized users only and will route the job to a high-priority queue.

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.

…-on-verify

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>

# Conflicts:
#	tests/integration/test_lists/test-db/l0_sanity_check.yml
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "The failed perf regression tests have been verified separately in PR#14916."

@chienchunhung
chienchunhung enabled auto-merge (squash) June 3, 2026 22:05
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51908 [ skip ] triggered by Bot. Commit: 6cd2948 Link to invocation

auto-merge was automatically disabled June 3, 2026 22:12

Pull request was closed

@chienchunhung chienchunhung reopened this Jun 3, 2026
@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "The failed perf regression tests have been verified separately in PR#14916."

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51908 [ skip ] completed with state SUCCESS. Commit: 6cd2948
Skipping testing for commit 6cd2948

Link to invocation

@chienchunhung
chienchunhung enabled auto-merge (squash) June 3, 2026 22:24
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51911 [ skip ] triggered by Bot. Commit: 6cd2948 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #51911 [ skip ] completed with state SUCCESS. Commit: 6cd2948
Skipping testing for commit 6cd2948

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.

5 participants