Skip to content

[None][bugfix] Fix Mamba preloaded HF model loading#15501

Open
fallintoplace wants to merge 1 commit into
NVIDIA:mainfrom
fallintoplace:fix-mamba-preloaded-hf-model
Open

[None][bugfix] Fix Mamba preloaded HF model loading#15501
fallintoplace wants to merge 1 commit into
NVIDIA:mainfrom
fallintoplace:fix-mamba-preloaded-hf-model

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jun 19, 2026

Copy link
Copy Markdown

What changed

MambaForCausalLM.from_hugging_face() now handles an already-loaded Hugging Face PreTrainedModel before checking filesystem paths.

Why

The preloaded-model path set hf_model and hf_config_or_dir, but hf_model_dir was only initialized for string inputs. The shared path check could therefore raise UnboundLocalError before conversion.

Validation

  • python3 -m py_compile tensorrt_llm/models/mamba/model.py
  • git diff --check -- tensorrt_llm/models/mamba/model.py

Summary by CodeRabbit

  • Bug Fixes

    • Optimized Mamba model weight loading process for preloaded Hugging Face models. The weight conversion logic has been refined to directly and efficiently process preloaded model instances, improving compatibility and performance. Complete backward compatibility is maintained for all existing remote model loading scenarios.
  • Chores

    • Updated copyright year information.

Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 63557291-4bd0-4c14-b6f8-3bfa1e36ea81

📥 Commits

Reviewing files that changed from the base of the PR and between a76c818 and 2d76c2c.

📒 Files selected for processing (1)
  • tensorrt_llm/models/mamba/model.py

📝 Walkthrough

Walkthrough

In tensorrt_llm/models/mamba/model.py, the MambaForCausalLM.from_hugging_face method gains a use_preloading branch that directly calls convert_hf_mamba(hf_model, dtype) when a preloaded HuggingFace model object is provided. The copyright year range is also extended to 2026.

Changes

Mamba preloaded model weight conversion

Layer / File(s) Summary
Preloaded HF model branch in from_hugging_face
tensorrt_llm/models/mamba/model.py
Adds a use_preloading conditional that calls convert_hf_mamba(hf_model, dtype) directly instead of going through the path/checkpoint loading branches. Copyright year updated to 2022-2026.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing a bug in Mamba preloaded HF model loading, which matches the core issue described in the PR objectives.
Description check ✅ Passed The PR description explains what changed and why, with validation steps provided, but lacks explicit Test Coverage section and PR Checklist items from the template.
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.

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

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.

1 participant