Skip to content

[https://nvbugs/6891030][fix] Default mamba_ssm_cache_dtype to None so "auto" follows the checkpoint dtype… - #20051

Closed
trtllm-agent wants to merge 1 commit into
NVIDIA:release/1.3from
tensorrt-cicd:repair-bot-bug6891030-release-1.3-cb2b0e3d6f12
Closed

trtllm-agent wants to merge 1 commit into
NVIDIA:release/1.3from
tensorrt-cicd:repair-bot-bug6891030-release-1.3-cb2b0e3d6f12

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: The TRT-LLM NemotronHConfig used for dense Nemotron-H checkpoints defaulted mamba_ssm_cache_dtype to "float32", so "auto" chose an fp32 state cache (76.4 GB at batch 512) that exceeds the V2 Mamba GPU quota.
  • Fix: Default mamba_ssm_cache_dtype to None so "auto" follows the checkpoint dtype; explicit values still win; parametrized CPU regression test added.
  • Original test: bash .repair-bot/reproduce/6891030-0c4d6fa6cb0d-1791533546825211065/tot/repro_driver.sh
  • 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

Links

Reproduction comparison

  • Failed commit: no_failed_commit
  • ToT: repro_on_tot at 0c4d6fa
    Signature: ========== 2 failed, 3860 deselected, 6 warnings in (0:06:27) ==========
  • Signature relation: not_comparable

Dev Engineer Review

  • NemotronHConfig now defaults mamba_ssm_cache_dtype to None. For checkpoints without a declared value, "auto" can resolve to the checkpoint dtype instead of implicitly selecting FP32.
  • Explicit checkpoint values remain covered by the regression test. The change alters the constructor default; callers that relied on an implicit FP32 default should be checked.
  • Current review finding counts and test execution results were not provided.

QA Engineer Review

  • Modified tests/unittest/_torch/test_custom_config_registration.py. The parameterized test_nemotron_h_dense_ssm_cache_dtype checks behavior when the dtype is absent and when it is explicitly set to float32.
  • The test is listed in tests/integration/test_lists/test-db/l0_cpu.yml.
  • Coverage verdict: sufficient for the absent-versus-declared dtype resolution behavior. Test execution results were not provided.

Per-File QA Perspective

  • tensorrt_llm/_torch/configs/nemotron_h.py: Verify that a dense Nemotron-H checkpoint without mamba_ssm_cache_dtype leaves the field unset, and that "auto" resolves from the checkpoint dtype. Also verify that explicit checkpoint values continue to take precedence.
  • tests/unittest/_torch/test_custom_config_registration.py: Covers automatic cache-dtype resolution for absent and explicitly declared values. The test is listed in the CPU CI test list at tests/integration/test_lists/test-db/l0_cpu.yml.

…he dtype to float32

NemotronHConfig (registered over CONFIG_MAPPING["nemotron_h"] for
checkpoints whose hybrid_override_pattern contains MLP layers) defaulted
mamba_ssm_cache_dtype to "float32". Dense checkpoints such as
NVIDIA-Nemotron-Nano-12B-v2 do not declare the field, so
kv_cache_config.mamba_ssm_cache_dtype="auto" resolved to an fp32
recurrent-state cache instead of the checkpoint dtype, doubling the state
memory. The V2 Mamba cache manager then rejected the GPU quota at
max_batch_size=512 on H100.

Leave the field unset unless the checkpoint declares it, restoring the
resolution these checkpoints had through their remote config.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: cf789302-957b-45ab-bc5a-6cd4eeba587f

📥 Commits

Reviewing files that changed from the base of the PR and between 95d7ce2 and 5397f47.


📒 Files selected for processing (2)
  • tensorrt_llm/_torch/configs/nemotron_h.py
  • tests/unittest/_torch/test_custom_config_registration.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.



Walkthrough

Nemotron-H now leaves mamba_ssm_cache_dtype unset by default. Tests cover resolution from the checkpoint dtype when the setting is absent and precedence for an explicit cache dtype.

Changes

Nemotron-H cache dtype resolution

Layer / File(s) Summary
Default and resolution coverage
tensorrt_llm/_torch/configs/nemotron_h.py, tests/unittest/_torch/test_custom_config_registration.py
The config defaults mamba_ssm_cache_dtype to None. Tests verify that an absent setting resolves to the checkpoint’s bfloat16 dtype, while an explicit float32 setting takes precedence.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: bowenfu

Merge Risk: ⚪ Minimal · up to 5397f

The cache dtype fix and regression coverage are ready to merge with no identified current-head risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the bug fix and the primary behavior change: setting mamba_ssm_cache_dtype to None so auto follows the checkpoint dtype.
Description check Passed The description explains the root cause, fix, expected behavior, regression test, verification plan, and bug reference. It is sufficiently complete, although it uses a Test plan heading instead of the…
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.


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Stamp on behalf of runtime devs, delegating proper review to @NVIDIA/trt-llm-devs; please ping me if you think this is not accurate

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

Approving — the comments below are optional touch-ups, not blockers.

This fixes the regression, but only inside the TRT-LLM shim. The native transformers NemotronHConfig (5.5.4, configuration_nemotron_h.py:121) also defaults mamba_ssm_cache_dtype to "float32", and NemotronHConfig.from_dict hands every natively representable pattern to that class ([tensorrt_llm/_torch/configs/nemotron_h.py:106](https://github.com/NVIDIA/TensorRT-LLM/pull/20051/files#diff-4e82e7f8e39268e5ed3b250721baa962a54644600e0e28b6bb698f2b6e8ab1eeR106)-111). Two consequences:

  • Once requirements.txt moves past transformers 5.6.2, which fixes the - pattern upstream, dense checkpoints will load through the native class and "auto" will go back to fp32. The isinstance(cfg, NemotronHConfig) assertion in the new test will fail at that point, which is good, but the fix itself won't carry over. A more durable fix is to make resolve_ssm_cache_dtype ignore a value that only comes from the class default (for example, compare against config.to_diff_dict(), or check whether the key was in the raw config dict). That can be a follow-up, but please at least add a TODO next to the default that links it to the transformers pin.
  • The class docstring ([nemotron_h.py:79](https://github.com/NVIDIA/TensorRT-LLM/pull/20051/files#diff-4e82e7f8e39268e5ed3b250721baa962a54644600e0e28b6bb698f2b6e8ab1eeR79)-82) says the shim keeps "exact current behaviour" relative to native. That's no longer true for this field, so please update it.

Please also add the post-fix result of the repro (the two nemotron_nano_12b_v2 bench cases on H100) to the description. Right now the only signature shown is the failing ToT run, so the "verified on the same GPU" checkbox has no evidence behind it.

# do not, and kv_cache_config.mamba_ssm_cache_dtype="auto" must then
# resolve to the checkpoint dtype rather than an implicit fp32 state
# cache (twice the recurrent-state memory).
mamba_ssm_cache_dtype=None,

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.

Native transformers NemotronHConfig defaults this to "float32", so this line makes the shim deliberately differ from the native class. Please say so in the comment and add a TODO: when the transformers pin reaches ≥5.6.2, dense checkpoints stop using this class and the fp32 default comes back unless resolve_ssm_cache_dtype learns to ignore a class-default value. The current comment also explains the motivation ("twice the recurrent-state memory"). That belongs in the PR description; the comment should just state the contract: None means not declared by the checkpoint, so "auto" falls back to torch_dtype.

ids=["undeclared", "declared_fp32"],
)
def test_nemotron_h_dense_ssm_cache_dtype(tmp_path, declared, expected):
# Dense Nemotron-H checkpoints (e.g. NVIDIA-Nemotron-Nano-12B-v2) do not

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.

Nit: the H100 / max_batch_size=512 detail describes the incident, not the behavior under test, and it will go stale. Something like "undeclared → checkpoint dtype; declared value wins" is enough here. The incident context fits better in the PR description.

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

@trtllm-agent

Copy link
Copy Markdown
Collaborator Author

NVBug 6891030 is closed as Bug - Fix unknown. The linked bug appears resolved elsewhere or for a reason that does not prove this PR is redundant. This PR should be judged on its own merits; repair-bot is not auto-closing it.

@BowenFu

BowenFu commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

#20284 merged this morning and makes the same change (mamba_ssm_cache_dtype defaulting to None), plus the cache-size calculation. Unless this covers something that PR doesn't, I think this can be closed. Needs a decision before merge.

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.

5 participants