Skip to content

[None][feature] Add env variables to help debugging mamba modules. - #14170

Merged
Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/legacy-py-mamba-env
May 21, 2026
Merged

[None][feature] Add env variables to help debugging mamba modules.#14170
Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/legacy-py-mamba-env

Conversation

@Wanli-Jiang

@Wanli-Jiang Wanli-Jiang commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Features

  • Add TRTLLM_USE_PY_MAMBA (default 0) to use legacy python mamba cache manager. Default is not use py mamba cache manager.
  • Add TRTLLM_USE_MAMBA_REPLAY (default 1) to use replay for mamba. Default is enable replay.

Summary by CodeRabbit

  • New Features

    • Added support for Python Mamba cache manager selection via environment variable
  • Bug Fixes

    • Added mutual exclusivity validation to prevent conflicting Mamba cache manager environment variable settings
    • Added warning when Python Mamba override is specified during disaggregated serving mode

Review Change Stack

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)

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

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request adds TRTLLM_USE_PY_MAMBA environment variable support as an alternative override mechanism for Python mamba cache manager selection. A new use_py_mamba_cache_manager() helper is introduced alongside enforcement of mutual exclusivity between C++ and Python mamba overrides. The override is integrated into KV cache manager routing and unified pool decisions, with special handling to disable the override in disaggregated serving mode.

Changes

Python Mamba Cache Manager Override

Layer / File(s) Summary
Core Python mamba override helpers
tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
Introduces use_py_mamba_cache_manager() to read TRTLLM_USE_PY_MAMBA environment variable, and updates use_cpp_mamba_cache_manager() to enforce mutual exclusivity by raising ValueError when both TRTLLM_USE_CPP_MAMBA and TRTLLM_USE_PY_MAMBA are enabled.
KV cache routing and pool integration
tensorrt_llm/_torch/pyexecutor/_util.py, tensorrt_llm/_torch/model_config.py
Integrates Python mamba override into cache manager selection by routing through both helper functions, updates the unified KV pool predicate to include TRTLLM_USE_PY_MAMBA as a trigger for split-pool mode alongside C++ mamba and disaggregation, expands docstrings and V1 hybrid routing conditions to document the override behavior.
Disaggregated serving mode override
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
Clears TRTLLM_USE_PY_MAMBA during disaggregated executor creation and logs a warning that the override is unsupported in this mode, preventing downstream logic from being affected by the environment variable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions adding env variables for debugging, but the actual implementation focuses on adding TRTLLM_USE_PY_MAMBA to enable the legacy Python mamba cache manager—a feature, not a debugging aid. Revise the title to accurately reflect the main change: '[None][feature] Add TRTLLM_USE_PY_MAMBA to enable legacy Python mamba cache manager' or similar, removing the misleading 'debugging' reference.
Description check ⚠️ Warning PR description lacks critical sections from template. The Description and Test Coverage sections are empty with only template comments, making it impossible to understand the rationale, implementation details, or test coverage for the changes. Fill in the Description section with a clear explanation of why the TRTLLM_USE_PY_MAMBA environment variable is needed and how it works. Document the test cases that validate these environment variable changes and the disaggregation logic.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
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.

✏️ 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: 2

🤖 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 `@tensorrt_llm/_torch/model_config.py`:
- Around line 55-59: The predicate that computes use_split_pool in
model_config.py should enforce mutual exclusivity between TRTLLM_USE_CPP_MAMBA
and TRTLLM_USE_PY_MAMBA: before computing use_split_pool (and before returning
not (use_split_pool or use_spec)), explicitly read both os.environ values for
'TRTLLM_USE_CPP_MAMBA' and 'TRTLLM_USE_PY_MAMBA' and if both are set to '1'
raise a clear exception (or log and abort) so the code does not proceed
silently; keep the rest of the logic (is_disagg, spec_config, use_spec, final
return) unchanged but only after this conflict check.

In `@tensorrt_llm/_torch/pyexecutor/py_executor_creator.py`:
- Around line 838-842: The code currently calls
os.environ.pop("TRTLLM_USE_PY_MAMBA", "0") which mutates global process state
and can cause cross-executor interference; replace the pop with a non-mutating
read (e.g. os.environ.get("TRTLLM_USE_PY_MAMBA", "0") or pass an explicit
per-executor flag) and base the routing decision on that local value, keeping
the existing logger.warning message (the string referencing TRTLLM_USE_PY_MAMBA
and the instruction to use
cache_transceiver_config.transceiver_runtime='PYTHON') so behavior stays
identical but without changing os.environ; update any other occurrence (the
second instance mentioned) similarly.
🪄 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: 5d1698ce-844d-4fdb-99e2-33b7474695fb

📥 Commits

Reviewing files that changed from the base of the PR and between 40a4223 and 0e29cca.

📒 Files selected for processing (4)
  • tensorrt_llm/_torch/model_config.py
  • tensorrt_llm/_torch/pyexecutor/_util.py
  • tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py

Comment thread tensorrt_llm/_torch/model_config.py
Comment thread tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48669 [ run ] triggered by Bot. Commit: 6b611ad Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48669 [ run ] completed with state SUCCESS. Commit: 6b611ad
/LLM/main/L0_MergeRequest_PR pipeline #38448 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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48687 [ run ] triggered by Bot. Commit: 6b611ad Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48687 [ run ] completed with state SUCCESS. Commit: 6b611ad
/LLM/main/L0_MergeRequest_PR pipeline #38464 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

@Wanli-Jiang
Wanli-Jiang force-pushed the user/williamj/legacy-py-mamba-env branch from 6b611ad to 464e3c1 Compare May 18, 2026 07:51
@Wanli-Jiang Wanli-Jiang changed the title [None][feature] Add TRTLLM_USE_PY_MAMBA to use legacy python mamba cache manager [None][feature] Add env variables to help debugging mamba modules. May 18, 2026
@Wanli-Jiang
Wanli-Jiang force-pushed the user/williamj/legacy-py-mamba-env branch from 464e3c1 to a4f67fd Compare May 18, 2026 07:57
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@HuiGao-NV HuiGao-NV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #48863 [ run ] triggered by Bot. Commit: a4f67fd Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49033 [ run ] triggered by Bot. Commit: a4f67fd Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49191 [ run ] triggered by Bot. Commit: a4f67fd Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49191 [ run ] completed with state FAILURE. Commit: a4f67fd
/LLM/main/L0_MergeRequest_PR pipeline #38868 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: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
@Wanli-Jiang
Wanli-Jiang force-pushed the user/williamj/legacy-py-mamba-env branch from 7e081fc to ba18408 Compare May 20, 2026 06:56
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49380 [ run ] triggered by Bot. Commit: ba18408 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49572 [ run ] triggered by Bot. Commit: ba18408 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "CI passed at different runs"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49616 [ skip ] triggered by Bot. Commit: ba18408 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

Link to invocation

@Wanli-Jiang
Wanli-Jiang merged commit 57a1b84 into NVIDIA:main May 21, 2026
7 checks passed
xxi-nv pushed a commit to xxi-nv/TensorRT-LLM that referenced this pull request May 22, 2026
…VIDIA#14170)

Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@users.noreply.github.com>
bmarimuthu-nv pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request May 28, 2026
…VIDIA#14170)

Signed-off-by: Wanli Jiang <35160485+Wanli-Jiang@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.

5 participants