Skip to content

[None][fix] Import the model KV geometry spec under its own name in the Mamba manager tests - #22327

Merged
Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/fix-mamba-test-layer-spec-shadow
Nov 16, 2026
Merged

Wanli-Jiang merged 1 commit into
NVIDIA:mainfrom
Wanli-Jiang:user/williamj/fix-mamba-test-layer-spec-shadow

Conversation

@Wanli-Jiang

@Wanli-Jiang Wanli-Jiang commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Dev Engineer Review

  • The change renames the import alias for KVCacheLayerSpec from tensorrt_llm._torch.model_config to ModelKVCacheLayerSpec in one test module. It does not change source code.
  • The alias separates the model-config spec from the V2 storage layer spec, which keeps the KVCacheLayerSpec name. This removes the name collision that the PR reports caused Ruff F811 and a wrong spec construction in the Skip Softmax routing test.
  • The diff touches only the import line and one constructor call inside test_skip_softmax_hybrid_follows_the_dense_manager_routing. No public API or runtime behavior changes.

QA Engineer Review

Test files changed:

  • tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py (modified, +2/-2)

Test functions changed:

  • test_skip_softmax_hybrid_follows_the_dense_manager_routing: builds variable-geometry layer specs with ModelKVCacheLayerSpec. The PR reports that the parametrized case [False-0-True-KVCacheManagerV2] previously raised a TypeError for num_q_heads. The PR reports that this case passes after the change. This was not verified in this review.

Coverage verdict: sufficient for the reported fix. The change is a naming fix with no new coverage. Test-list membership in test-db/ or qa/ was not checked in this review.

Per-File QA Perspective:

  • tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py: Covers the Skip Softmax hybrid routing with variable-geometry KV layer specs. Confirm that the parametrized KVCacheManagerV2 case passes and that the Ruff check no longer reports F811.

Description

test_mamba_cache_manager.py imports two different classes named KVCacheLayerSpec: the model's KV geometry spec from tensorrt_llm._torch.model_config (added by #21553) and the V2 storage layer spec from kv_cache_manager_v2 (added by #21972). The second import rebinds the name, so:

  • ruff reports F811 on the file. The Pre-commit Check runs hooks on every file a PR changes, so it fails for any PR that touches this file.
  • test_skip_softmax_hybrid_follows_the_dense_manager_routing[False-0-True-KVCacheManagerV2] builds the V2 storage spec with head_dim/num_kv_heads/num_q_heads and raises TypeError: KVCacheLayerSpec.__init__() got an unexpected keyword argument 'num_q_heads'.

The model spec is now imported as ModelKVCacheLayerSpec, the alias test_kv_cache_estimation.py already uses. The V2 storage spec keeps its name for _fp8_draft_layer_spec.

Test Coverage

  • tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py::test_skip_softmax_hybrid_follows_the_dense_manager_routing
  • pre-commit run --files tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py passes (fails with F811 on main).

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.

@Wanli-Jiang
Wanli-Jiang marked this pull request as ready for review November 16, 2026 09:31
@Wanli-Jiang
Wanli-Jiang requested a review from a team as a code owner November 16, 2026 09:31
@Wanli-Jiang

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

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

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The test module aliases the model-config KVCacheLayerSpec as ModelKVCacheLayerSpec and uses the alias when constructing layer specs in the variable-geometry test. Test arguments and logic are unchanged.

Changes

KV cache test

Layer / File(s) Summary
Use explicit layer spec alias
tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py
The model-config KVCacheLayerSpec import and its use in the variable-geometry test now use the ModelKVCacheLayerSpec alias. Test arguments and logic are unchanged.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Other

Merge Risk: Minimal · up to 87e0f

This is a test-only rename that fixes a name collision between two same-named spec classes. It does not change production behavior, and the merge risk is minimal.

Security architecture risk: Minimal · up to 87e0f

The change disambiguates which existing class a unit test constructs. No introduced or worsened architecture-level security or failure-containment risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the model KV geometry spec is imported under the name ModelKVCacheLayerSpec in the Mamba cache manager tests. It follows the [None][fix] template and is specific to th…
Description check Passed The description covers the problem (duplicate KVCacheLayerSpec import causing Ruff F811 and a TypeError in a parametrized test), the solution (alias to ModelKVCacheLayerSpec), and test coverage (the a…
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.
Full details: Title check

Explanation

The title names the main change: the model KV geometry spec is imported under the name ModelKVCacheLayerSpec in the Mamba cache manager tests. It follows the [None][fix] template and is specific to the changeset. It is a fix for a duplicate-name import that triggers Ruff F811 and a TypeError in one test. The title is 91 characters, which is slightly long but still a single clear sentence.

Full details: Description check

Explanation

The description covers the problem (duplicate KVCacheLayerSpec import causing Ruff F811 and a TypeError in a parametrized test), the solution (alias to ModelKVCacheLayerSpec), and test coverage (the affected test and the pre-commit run). It follows the template's ticket/type title format in the title. The Description section is short, but it explains what and why. The checklist is ticked. The template's PR Checklist items are not individually verified, and no ticket reference is given, which is acceptable under [None].

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1c46994 and 87e0f8f.

Files selected for processing: 1

  • tests/unittest/_torch/pyexecutor/kv_cache/test_mamba_cache_manager.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85140 [ run ] triggered by Bot. Commit: 87e0f8f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85140 [ run ] completed with state SUCCESS. Commit: 87e0f8f
/LLM/main/L0_MergeRequest_PR pipeline #70475 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants