Skip to content

[None][feat] BREAKING: Add native KV cache V2 sleep/wake - #21221

Merged
chienchunhung merged 1 commit into
NVIDIA:mainfrom
chienchunhung:dev/kvcm-v2-native-sleep
Dec 1, 2026
Merged

chienchunhung merged 1 commit into
NVIDIA:mainfrom
chienchunhung:dev/kvcm-v2-native-sleep

Conversation

@chienchunhung

@chienchunhung chienchunhung commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Enable native KVCacheManagerV2 sleep/wake without falling back to V1. Release physical backing, retain captured CUDA graphs and stable storage interfaces, and restore valid execution state before inference resumes.

Scope

  • A shut-down manager rejects sleep/wake; a cache without backing rejects resize. Sleep-critical operations recheck poison under the manager lock. Batch/cache teardown removes non-owning registry entries under the same lock. MPI exempts only peers actually rebuilding V2 KV from the normal wake ACK deadline.
  • Native lifecycle supports discard, best-effort preservation, Batch/sparse restoration, and recoverable local rollback; held-first offload now excludes failed REMOTE capacity from preflight.
  • Executor reconstruction recreates padding/guard caches without graph recapture, while the control caller owns manager access and the executor loop remains parked.
  • KV restoration refreshes bindings and streaming events, separates prefix loss from weight-reset notifications, and delegates replay-slot restoration to the current model-family owners.
  • MPI/Ray controls keep admission closed through transitions and fail closed after uncertain group execution; regression tests cover capacity refusal, real staging-lender rejection, family-owned replay indices, and locality-domain rejection before mutation.

Compatibility and limits: Sleep no longer selects V1 automatically. Ray sleep must use LLM.release() or AsyncLLM.release(); private/direct sleep RPCs and rank-selected/nonblocking wakeup are rejected. V2 KV sleep rejects multiple locality domains, transceivers, KV-moving connectors, attached lenders, allocated MiniMaxM3 index-V buffers, mixed V1/V2 managers, and mixed-precision KV pools. Weights-only release remains available. Stable virtual addresses do not preserve external registrations. This PR does not preserve live serving requests or implement Snapshot process restore.

Failure and wait contract: Unrecovered or uncertain multi-worker execution requires group restart. Actual drain and V2 KV reconstruction have no fixed deadline; unrelated wake acknowledgements remain bounded. Stalled reconstruction requires operator action. Validation/abort retain their existing limits. Capacity preflight does not reserve memory or guarantee later remote health. See the sleep/wake guide for the full mode and recovery contracts.

Verification

Revision: be96ebf12a, rebased onto upstream 9d50cf3c65. One signed-off commit; original authorship retained.

  • The RPC regression checks that a parking rejection reaches the correct client through the response stream, while unrelated runtime errors still propagate. The CUDA graph test now checks the required KV buffer explicitly. Sync and async Ray release reject a shut-down executor before dispatch. The private KV stub now declares the existing native SSM block-index method.
  • Local: required hooks, git diff --check, and strict Pyrefly on the reported virtual-memory test passed. 279 repository configuration/replay tests passed. Isolated CPU harnesses passed 72 MPI-control, 37 connected-transport/Ray, and 26 RPC/native-control checks; 12 release API cases passed, including both shutdown regressions. The final advisory Pyrefly report dropped both shutdown warnings and all seven missing SSM-method warnings. The additional test diagnostic is an AsyncMock.assert_not_awaited call; the fixture explicitly installs an AsyncMock. Remaining fixture and optional-type warnings are not a clean type-check claim. These local tests did not run real MPI, Ray actors, CUDA, or the C++ gtests.
  • Previous L0 #73188 failed on 5a0ad15bb1. Two GB200 four-rank MNNVL cases passed; the four required H100 MPI/Ray TP2 cases did not run. Recheck all six cases on this revision.
  • Full multi-GPU pre-merge CI: L0 #73347 started on this exact commit (helper #88340). Results and all six required multi-GPU cases are pending. L0 #73336 tested the superseded revision.

Notes

Integration follow-up (whichever PR lands second): once #21221 and #21598 are both present, report failure_reason=sleep_wakeup from the Ray driver after a terminal sleep/wake failure. Cover the combined public status reply. Admission already stays closed.

Successor to Yi Zhang's #20087, kept as one signed-off commit with Yi's authorship. #21598 is independent lifecycle work, not a dependency or proof of process restore.

Follow-up PRs (not merge requirements):

  • External KV users. Keep the attached-lender guard, including for idle lenders. Before enabling this path, fence new leases/copies, prove old accesses have ended, and deregister affected GPU/HOST ranges. After restoring bindings, re-register and publish a fresh peer identity. Reverse completed steps on rollback; keep the group closed if safety is uncertain.

  • Placement and locality. Add a placement epoch distinct from prefix validity before exporting slot references across wake. Qualify per-domain release, restore and index refresh before enabling multi-locality-domain sleep.

  • Native and Ray lifecycle. Per Yi's review, retain native living-cache support here; audit direct callers before removing wake-only state. Ray all-rank post-drain preparation, safe pre-mutation abort and automatic recovery need separate qualification. The current contract requires restart after an uncertain transition.

  • Optional tests and maintenance. Add single-GPU MPI discard/preserve coverage; measure wake latency and host re-pinning on broader profiles. Consider consistent restore/zeroing and page/tree-reset helpers, permanent host-fill error reporting, typed HTTP conflicts, and native API wording. These do not replace the required multi-GPU runs.

  • Reviewed scope, coding guidelines, tests, documentation, API compatibility, dependencies, and ownership. No new configuration fields, dependencies, or ownership changes.

chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from af7661f to b69bc78 Compare October 29, 2026 00:19
chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from b69bc78 to 2ef6661 Compare October 29, 2026 01:42

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81292 [ run ] triggered by Bot. Commit: 2ef6661 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81292 [ run ] completed with state FAILURE. Commit: 2ef6661
/LLM/main/L0_MergeRequest_PR pipeline #66981 completed with status: 'FAILURE'

CI Report

⚠️ Resource Maintenance — Test Coverage Reduced:

Resource maintenance in LLM/main/L0_Test-x86_64-Single-GPU #9628: L40S-PyTorch-2 is temporarily paused due to Kubernetes agent provisioning and node issues.
Affected stages:
L40S-PyTorch-2

⚠️ 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
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from 2ef6661 to a022433 Compare October 29, 2026 16:39
chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from a022433 to bdc6786 Compare October 29, 2026 16:41
chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from bdc6786 to b5803e0 Compare October 29, 2026 16:42

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81463 [ run ] triggered by Bot. Commit: b5803e0 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81463 [ run ] completed with state SUCCESS. Commit: b5803e0
/LLM/main/L0_MergeRequest_PR pipeline #67134 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Either:

  • Wait for the PR to be fully approved — the label is added automatically once approval is complete. Having unresolved open comments is fine, or
  • If needed, ask a member of NVIDIA/trt-llm-ci-approvers to add the label manually.
    Then re-trigger CI with the same bot command (no rebase needed).

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

chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

Signed-off-by: Chien-Chun Hung <2679986+chienchunhung@users.noreply.github.com>
@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch 2 times, most recently from 57d7b99 to e433b19 Compare October 29, 2026 23:42
chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@chienchunhung
chienchunhung force-pushed the dev/kvcm-v2-native-sleep branch from e433b19 to a5ca974 Compare October 29, 2026 23:47
chienchunhung pushed a commit to chienchunhung/TensorRT-LLM that referenced this pull request Oct 29, 2026
Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

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

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81525 [ run ] triggered by Bot. Commit: a5ca974 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81526 [ run ] triggered by Bot. Commit: a5ca974 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github/21221-a5ca974 #81525 was force-killed by a newer pipeline run.
L0 job information not available (job may not have been triggered yet).

Link to superseding invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #86794 [ run ] triggered by Bot. Commit: 91979be Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #86794 [ run ] completed with state SUCCESS. Commit: 91979be
/LLM/main/L0_MergeRequest_PR pipeline #71962 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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87031 [ run ] triggered by Bot. Commit: 63e7158 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87031 [ run ] completed with state SUCCESS. Commit: 63e7158
/LLM/main/L0_MergeRequest_PR pipeline #72187 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

@litaotju

Copy link
Copy Markdown
Collaborator

I approved since the Runtime and KVCM key folks had approved this.

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

@chienchunhung

Copy link
Copy Markdown
Collaborator Author

/bot run --reuse-test 72187 --add-multi-gpu-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87090 [ run ] triggered by Bot. Commit: 63e7158 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87090 [ run ] completed with state SUCCESS. Commit: 63e7158
/LLM/main/L0_MergeRequest_PR pipeline #72246 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 --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87284 [ run ] triggered by Bot. Commit: dfc01ff Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87284 [ run ] completed with state SUCCESS. Commit: dfc01ff
/LLM/main/L0_MergeRequest_PR pipeline #72419 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 --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88163 [ run ] triggered by Bot. Commit: 5a0ad15 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88163 [ run ] completed with state SUCCESS. Commit: 5a0ad15
/LLM/main/L0_MergeRequest_PR pipeline #73188 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 --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88327 [ run ] triggered by Bot. Commit: cff18ab Link to invocation

Consolidate the implementation from NVIDIA#20087, originally authored by Yi Zhang, and continue it in NVIDIA#21221.

Release native GPU and host backing through V2 cache tiers. Preserve metadata addresses and refresh KV/SSM indices before graph replay. Integrate with MPI and Ray memory controls and add native, graph, and serving tests.

Include the successor self-review fix: reject V2 KV sleep with KV-moving connectors until their memory-registration lifecycle is supported. Keep capacity-only connectors and model-only sleep available.

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

Copy link
Copy Markdown
Collaborator Author

/bot run --add-multi-gpu-test --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88340 [ run ] triggered by Bot. Commit: be96ebf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88327 [ run ] completed with state ABORTED. Commit: cff18ab

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88340 [ run ] completed with state SUCCESS. Commit: be96ebf
/LLM/main/L0_MergeRequest_PR pipeline #73347 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 #88464 [ run ] triggered by Bot. Commit: be96ebf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #88464 [ run ] completed with state SUCCESS. Commit: be96ebf
/LLM/main/L0_MergeRequest_PR pipeline #73464 completed with status: 'SUCCESS'

CI Report

Link to invocation

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

Labels

api-breaking Accepted LLM API contract change that is backwards-incompatible ci: full pre-merge approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.