Skip to content

[https://nvbugs/6550132][fix] Preserve disaggregated Mamba cache routing - #17224

Open
trtllm-agent wants to merge 3 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6550132
Open

[https://nvbugs/6550132][fix] Preserve disaggregated Mamba cache routing#17224
trtllm-agent wants to merge 3 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6550132

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: Aggregated-only Mamba overrides were allowed to collide with the auto-resolved V2 route. The disaggregated check also read only object attributes, so a TorchLlmArgs.model_dump() nested dictionary was misclassified as aggregated serving.
  • Fix: Centralize the aggregated-only override predicate, preserve disaggregated V2 routing for both object and serialized dictionary configs, and keep shared V2 validation reachable.
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests
  • Cover serialized nested disaggregated config routing

Links

Dev Engineer Review

  • Added shared Mamba manager override handling.
  • Limited TLLM_MAMBA_MANAGER_PREFERENCE to aggregated serving.
  • Preserved transceiver-based manager selection for disaggregated serving.
  • Kept V2 block-reuse and rebalance validation reachable.
  • Updated Nemotron-H and Qwen3-Next defaults to avoid V2 selection when a V1 Mamba override is active.
  • Removed the stale nvbugs/6550132 waiver.
  • No public API changes were identified.
  • The implementation is consistent with the reported hybrid-model error fix.

QA Engineer Review

  • Added regression tests for disaggregated CPP and MIXED routing.
  • Added coverage for V1 overrides, unrecognized preferences, serialized disaggregation arguments, loose argument types, and explicit V2 conflicts.
  • Added hybrid default coverage for Nemotron-H and Qwen3-Next.
  • Modified test_hybrid_models_default_to_v2_and_python_transceiver.
  • No test functions were removed.
  • The tests are not individually listed in tests/integration/test_lists/.
  • The removed waives.txt entry covered the original nvbugs/6550132 regression.
  • Verdict: sufficient.

…mba override

Hybrid Mamba models default `use_kv_cache_manager_v2` to True for the hybrid
state layout. `TRTLLM_USE_PY_MAMBA=1` and `TLLM_MAMBA_MANAGER_PREFERENCE` in
(CPP, MIXED) select a mutually exclusive V1-route manager, and
`get_kv_cache_manager_cls` rejects that pair. A user who set only the env var
left the setting at "auto", which resolved to the model default of True, so the
factory raised about an "explicit" V2 the user never selected -- inside the MPI
worker, surfacing as "RuntimeError: Executor worker returned error".

Suppress the default at the producer instead of correcting it afterwards: the
hybrid `get_model_defaults` now propose V2 only when no V1-route override is
active, so the contradicted value is never proposed and nothing is downgraded.
The predicate lives next to `use_py_mamba_cache_manager()`, which already owns
these env vars, and returns False for disaggregated serving because both
overrides are aggregated-mode-only.

An explicit `use_kv_cache_manager_v2=True` still raises -- that is a genuine
user contradiction, which finally makes the "explicit" wording truthful.

`get_model_defaults` is called with None (perf-sanity transceiver precheck) and
with a plain dict (config-database test) as well as with `TorchLlmArgs`, so the
predicate reads `llm_args` via `getattr`; both loose forms now get the correct
answer rather than the precheck's silent "assuming V1" fallback, and are covered
by a new regression test.

Removes the now-stale waiver for the aggregated H100 parametrization.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
…aggregated serving

TLLM_MAMBA_MANAGER_PREFERENCE selects a compatibility (V1) Mamba manager, so
like TRTLLM_USE_PY_MAMBA it only applies in aggregated serving -- in disagg the
manager follows the transceiver configuration. It was missing that guard, and
get_kv_cache_manager_cls's is_disagg block does not return on a supported V2
route, so a hybrid model whose auto-resolved default is V2 fell through to the
preference branch and raised about an 'explicit' V2 the user never set.

Give the preference branch the same 'and not is_disagg' guard the sibling env
var already has.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

The change centralizes Mamba manager preference handling, limits environment overrides to aggregated serving, and updates Nemotron-H and Qwen3-Next defaults for disaggregation-aware V1/V2 selection. Tests cover preference variants, argument types, conflicts, and the restored Nemotron integration test.

Mamba cache-manager routing

Layer / File(s) Summary
Shared Mamba preference helpers
tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
Adds normalized environment preference handling and detects V1 overrides only when disaggregated transceiver configuration is absent.
Routing and model defaults
tensorrt_llm/_torch/pyexecutor/_util.py, tensorrt_llm/_torch/models/modeling_nemotron_h.py, tensorrt_llm/_torch/models/modeling_qwen3_next.py
Applies shared preference handling to executor routing and derives hybrid model V2 defaults from the V1 override state.
Routing regression coverage
tests/unittest/_torch/executor/test_mamba_cache_manager.py, tests/integration/test_lists/waives.txt
Tests aggregated and disaggregated routing, hybrid defaults, preference variants, argument types, conflicts, and the removed Nemotron test waiver.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModelDefaults
  participant MambaPreference
  participant PyExecutor
  participant Transceiver
  ModelDefaults->>MambaPreference: evaluate TLLM_MAMBA_MANAGER_PREFERENCE
  MambaPreference-->>ModelDefaults: V1 override status
  ModelDefaults->>PyExecutor: select KV-cache manager default
  PyExecutor->>Transceiver: inspect disaggregated configuration
  Transceiver-->>PyExecutor: transceiver routing state
  PyExecutor-->>ModelDefaults: apply V1 or V2 compatibility route
Loading

Possibly related PRs

Suggested labels: api-compatible

Suggested reviewers: allisonlim-nv, qijune, simengliu-nv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 title follows the required ticket and type format and clearly describes the disaggregated Mamba cache-routing fix.
Description check ✅ Passed The description explains the root cause, fix, testing, and bug reference, with only minor template heading and checklist differences.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unittest/_torch/executor/test_mamba_cache_manager.py (1)

518-668: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Cover disaggregated model_dump() mappings.

mamba_manager_override_forces_v1() uses attribute access, so {"cache_transceiver_config": {"backend": "NIXL"}} is treated as aggregated and incorrectly proposes V1. Add this case and update the helper to read mapping keys. Expect _proposed_use_v2(...) == {True}.

Test coverage: Added tests cover routing, defaults, overrides, and loose inputs. All changed tests are included through unittest/_torch/executor in the applicable test-db lists. Coverage remains insufficient until the populated mapping case is covered.

🤖 Prompt for 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.

In `@tests/unittest/_torch/executor/test_mamba_cache_manager.py` around lines 518
- 668, Update mamba_manager_override_forces_v1() to inspect
cache_transceiver_config from both object attributes and mapping keys, including
nested mapping values, so a disaggregated model_dump() with backend "NIXL" is
recognized and remains on V2. Extend
test_hybrid_defaults_accept_loose_llm_args() or a nearby helper test with the
populated mapping case and assert _proposed_use_v2(...) == {True}.

Source: Path instructions

🤖 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/pyexecutor/mamba_cache_manager.py`:
- Around line 235-252: Update mamba_manager_override_forces_v1 to read
cache_transceiver_config from both object and dictionary llm_args, then read
backend from either object or dictionary configuration. Ensure a populated
dictionary with a non-None backend is treated as disaggregated and does not
force the V1 route; add regression coverage for this case.

---

Outside diff comments:
In `@tests/unittest/_torch/executor/test_mamba_cache_manager.py`:
- Around line 518-668: Update mamba_manager_override_forces_v1() to inspect
cache_transceiver_config from both object attributes and mapping keys, including
nested mapping values, so a disaggregated model_dump() with backend "NIXL" is
recognized and remains on V2. Extend
test_hybrid_defaults_accept_loose_llm_args() or a nearby helper test with the
populated mapping case and assert _proposed_use_v2(...) == {True}.
🪄 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: 7fb942fc-e102-4d8b-9427-e0f38b241fbf

📥 Commits

Reviewing files that changed from the base of the PR and between 73efcee and 2968450.

📒 Files selected for processing (6)
  • tensorrt_llm/_torch/models/modeling_nemotron_h.py
  • tensorrt_llm/_torch/models/modeling_qwen3_next.py
  • tensorrt_llm/_torch/pyexecutor/_util.py
  • tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py
  • tests/integration/test_lists/waives.txt
  • tests/unittest/_torch/executor/test_mamba_cache_manager.py
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

Comment thread tensorrt_llm/_torch/pyexecutor/mamba_cache_manager.py Outdated

@StanleySun639 StanleySun639 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 if the target test case can pass.

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

Please update related doc under docs/ maybe in docs/source/features/kvcache.md

…g (By Agent)

Signed-off-by: Xiwen Yu <13230610+VALLIS-NERIA@users.noreply.github.com>
@VALLIS-NERIA

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63730 [ run ] triggered by Bot. Commit: 1f92b32 Link to invocation

@VALLIS-NERIA VALLIS-NERIA changed the title [https://nvbugs/6550132][fix] Add and not is_disagg to the TLLM_MAMBA_MANAGER_PREFERENCE branch… [https://nvbugs/6550132][fix] Preserve disaggregated Mamba cache routing Aug 4, 2026
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63730 [ run ] completed with state FAILURE. Commit: 1f92b32
/LLM/main/L0_MergeRequest_PR pipeline #51682 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

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