Skip to content

Fix Nemotron 3 SFT example: add Mamba modules to LoRA targets - #6775

Closed
davidnichols-ops wants to merge 1 commit into
huggingface:mainfrom
davidnichols-ops:fix/nemotron-3-example-target-modules
Closed

Fix Nemotron 3 SFT example: add Mamba modules to LoRA targets#6775
davidnichols-ops wants to merge 1 commit into
huggingface:mainfrom
davidnichols-ops:fix/nemotron-3-example-target-modules

Conversation

@davidnichols-ops

@davidnichols-ops davidnichols-ops commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • Replaced gate_proj with in_proj and out_proj in the LoRA target modules for the Nemotron 3 SFT example
  • Added explanatory comment about NemotronH's hybrid Mamba-Attention architecture

Why

NemotronH is a hybrid Mamba-Attention architecture. The previous target modules (q_proj k_proj v_proj o_proj gate_proj up_proj down_proj) had two problems:

  1. gate_proj does not exist in NemotronH. The MLP layers use up_proj/down_proj (standard MLP) or MoE variants, not gate_proj.
  2. Mamba layers were missing entirely. NemotronH models have Mamba SSM layers with in_proj/out_proj modules. In Nemotron-Nano-9B-v2, 52 of 56 layers are Mamba. Omitting these from LoRA targets means 93% of the model is frozen during fine-tuning, resulting in zero learning (DPO loss stays at ln(2)).

See huggingface/peft#3554 for the full analysis.

What Changed

  • examples/scripts/sft_nemotron_3.py: Changed --lora_target_modules from q_proj k_proj v_proj o_proj gate_proj up_proj down_proj to q_proj k_proj v_proj o_proj in_proj out_proj up_proj down_proj
  • Added a comment block explaining the hybrid architecture and why Mamba modules must be included

Test plan

  • Example runs without errors on Nemotron-3-Nano-30B-A3B
  • LoRA adapter targets both Mamba and Attention layers

Note

Low Risk
Documentation and example CLI defaults only; no library or training runtime code changes.

Overview
Updates the Nemotron 3 SFT example so LoRA actually trains the hybrid model instead of mostly freezing it.

The sample accelerate command now uses in_proj and out_proj instead of gate_proj, and keeps attention/MLP targets (q_proj, k_proj, v_proj, o_proj, up_proj, down_proj). gate_proj is not part of NemotronH, and without the Mamba projections most layers stay frozen.

A short module docstring explains why NemotronH needs both Mamba and attention/MLP modules in --lora_target_modules, with a link to the PEFT issue.

Reviewed by Cursor Bugbot for commit a3e38df. Bugbot is set up for automated code reviews on this repo. Configure here.

NemotronH is a hybrid Mamba-Attention architecture. The previous target
modules (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
only covered attention and MLP layers. gate_proj does not exist in
NemotronH, and the Mamba layers (in_proj, out_proj) were missing entirely.

Since Mamba layers are the majority in NemotronH models (e.g. 52/56 in
Nemotron-Nano-9B-v2), omitting them from LoRA targets means most of the
model is frozen during fine-tuning, resulting in zero learning.

See huggingface/peft#3554
@github-actions

Copy link
Copy Markdown
Contributor

Your PR has been closed because it does not follow the required PR template. Please open a new PR following the template. See CONTRIBUTING.md for guidance.

@github-actions github-actions Bot closed this Aug 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a3e38df. Configure here.

--lora_r 8 \
--lora_alpha 16 \
--lora_target_modules q_proj k_proj v_proj o_proj gate_proj up_proj down_proj
--lora_target_modules q_proj k_proj v_proj o_proj in_proj out_proj up_proj down_proj

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid Mamba LoRA out_proj target

High Severity

Adding out_proj to --lora_target_modules breaks NemotronH LoRA. Mamba mixers feed out_proj.weight into fused kernels, so LoRA on that module is skipped or rejected by PEFT, and adapters can fail at merge. Including in_proj is the useful Mamba change here; out_proj is not a valid target for this architecture.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a3e38df. Configure here.

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