Skip to content

[None][feat] Add support for FlexKV#12512

Merged
pcastonguay merged 2 commits into
NVIDIA:mainfrom
pcastonguay:feature/support_flexkv
Mar 27, 2026
Merged

[None][feat] Add support for FlexKV#12512
pcastonguay merged 2 commits into
NVIDIA:mainfrom
pcastonguay:feature/support_flexkv

Conversation

@pcastonguay
Copy link
Copy Markdown
Collaborator

@pcastonguay pcastonguay commented Mar 24, 2026

Summary by CodeRabbit

  • New Features
    • Added ability to query request completion status.
    • Enhanced KV cache connector with initialization synchronization and metadata handling.
    • Extended request tracking to include connector-matched token metrics.

Description

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

To see a list of available CI bot commands, please comment /bot help.

axxx03 and others added 2 commits March 24, 2026 10:58
Signed-off-by: scutizhang <[email protected]>
Signed-off-by: Patrice Castonguay <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Introduced isFinishedWithoutError() method to detect whether requests finished without error conditions; enhanced KV cache connector with initialization blocking and metadata handling; integrated metadata handling into executor loops with state tracking.

Changes

Cohort / File(s) Summary
C++ API Additions
cpp/include/tensorrt_llm/batch_manager/llmRequest.h, cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
Added isFinishedWithoutError() method to check finish reasons across beams; exposed as read-only Python property is_finished_without_error.
KV Cache Connector Enhancements
tensorrt_llm/_torch/pyexecutor/kv_cache_connector.py
Added wait_for_initialization() blocking method to scheduler and manager; updated get_num_new_matched_tokens() to persist matched token count to request; updated handle_metadata() to early-return when scheduler output is unavailable.
Executor Integration
tensorrt_llm/_torch/pyexecutor/py_executor.py, tensorrt_llm/_torch/pyexecutor/llm_request.py
Added blocking KV connector initialization call after hook registration; integrated handle_metadata() calls before batch loading in executor loops; added py_num_connector_matched_tokens state tracking to 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 0.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 largely incomplete and uses the template placeholder text without providing actual implementation details, rationale, or test coverage information. Replace template placeholders with concrete details: explain the FlexKV feature being added, why it's needed, what test coverage exists, and confirm all checklist items are properly addressed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates the main feature being added (FlexKV support) and is concise and specific.

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/kv_cache_connector.py`:
- Around line 498-500: The early return when self._scheduler_output is None
allows stale _metadata to persist; update handle_metadata() so that when
self._scheduler_output is None it explicitly calls _clear_connector_meta()
before returning (or alternatively ensure start_load_kv() implementations check
for and handle missing metadata), i.e., modify the flow around
bind_connector_meta(), _scheduler_output, and _clear_connector_meta() so
_metadata is cleared whenever _scheduler_output is absent to avoid passing stale
metadata into start_load_kv().

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c77cd546-3774-4188-8ba2-4c2b9cb7e6a3

📥 Commits

Reviewing files that changed from the base of the PR and between 73a02ee and 800372a.

📒 Files selected for processing (5)
  • cpp/include/tensorrt_llm/batch_manager/llmRequest.h
  • cpp/tensorrt_llm/nanobind/batch_manager/bindings.cpp
  • tensorrt_llm/_torch/pyexecutor/kv_cache_connector.py
  • tensorrt_llm/_torch/pyexecutor/llm_request.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py

Comment thread tensorrt_llm/_torch/pyexecutor/kv_cache_connector.py
@pcastonguay pcastonguay force-pushed the feature/support_flexkv branch from 800372a to c5b1399 Compare March 24, 2026 17:59
@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40158 [ run ] triggered by Bot. Commit: c5b1399 Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

Same changes as in #9698, moving to my fork to merge more quickly.

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40158 [ run ] completed with state SUCCESS. Commit: c5b1399
/LLM/main/L0_MergeRequest_PR pipeline #31303 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

Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40324 [ run ] triggered by Bot. Commit: c5b1399 Link to invocation

@pcastonguay pcastonguay enabled auto-merge (squash) March 25, 2026 20:50
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40324 [ run ] completed with state SUCCESS. Commit: c5b1399
/LLM/main/L0_MergeRequest_PR pipeline #31434 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

Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40387 [ run ] triggered by Bot. Commit: c5b1399 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40387 [ run ] completed with state FAILURE. Commit: c5b1399
/LLM/main/L0_MergeRequest_PR pipeline #31484 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

Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40452 [ run ] triggered by Bot. Commit: c5b1399 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40452 [ run ] completed with state SUCCESS. Commit: c5b1399
/LLM/main/L0_MergeRequest_PR pipeline #31542 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

Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40469 [ run ] triggered by Bot. Commit: c5b1399 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40469 [ run ] completed with state SUCCESS. Commit: c5b1399
/LLM/main/L0_MergeRequest_PR pipeline #31558 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

Link to invocation

@pcastonguay
Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "Flaky multi-GPU Nemotron test"

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40511 [ skip ] triggered by Bot. Commit: c5b1399 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40511 [ skip ] completed with state SUCCESS. Commit: c5b1399
Skipping testing for commit c5b1399

Link to invocation

@pcastonguay pcastonguay merged commit 789494f into NVIDIA:main Mar 27, 2026
5 checks passed
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