You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEFT's default LoRA target modules for nemotron_h (added in PR #3289) only target attention projections (q_proj, k_proj, v_proj, o_proj). For NemotronH's hybrid Mamba-2 + Attention architecture, this means LoRA only touches 4 out of 56 layers (7.1%) — the other 52 layers are Mamba SSM layers with different parameter names (in_proj, out_proj, A_log, D, dt, x_proj, z_proj).
Worse, PEFT silently skips target module names that don't exist in the model. There's no warning that the configured target modules only matched a small fraction of layers. The user sees training "complete" with loss not improving, and has no idea why.
Reproduction
We ran DPO (LoRA) on nvidia/NVIDIA-Nemotron-Nano-9B-v2 with the default PEFT target modules:
Where M = Mamba, * = Attention. Only 4 layers are attention. The other 52 are Mamba layers with parameters in_proj, out_proj, A_log, D — none of which were targeted by LoRA.
The combination means: PEFT defaults only target attention layers, and PEFT actively blocks you from targeting Mamba layers
No warning is emitted when target modules match an unusually low number of parameters
Proposed Fixes
Fix 1: Warn on low coverage
When LoraConfig.target_modules matches fewer than N% of linear layers in the model, emit a warning:
ifmatched_layers/total_linear_layers<0.3:
warnings.warn(
f"LoRA target modules only matched {matched_layers}/{total_linear_layers} "f"linear layers ({100*matched/total:.1f}%). For hybrid architectures like "f"NemotronH, consider including Mamba modules (in_proj, out_proj) in target_modules."
)
Add documentation for hybrid Mamba+Attention models showing the correct target modules:
# For NemotronH / Jamba / Granite-H hybrid models:LoraConfig(
target_modules=[
# Attention layers"q_proj", "k_proj", "v_proj", "o_proj",
# Mamba layers (requires removing from mamba_model_types check)"in_proj", "out_proj", "x_proj", "dt_proj",
],
# Skip: conv1d, A_log, D (structured SSM parameters, not suitable for LoRA)
)
Fix 3: Reconsider the Mamba module ban
PR #2562 banned Mamba modules from LoRA targeting due to shape issues. But in_proj and out_proj are standard nn.Linear layers — they should be LoRA-compatible. The ban should be scoped to conv1d and structured SSM parameters (A_log, D), not all Mamba modules.
Problem
PEFT's default LoRA target modules for
nemotron_h(added in PR #3289) only target attention projections (q_proj,k_proj,v_proj,o_proj). For NemotronH's hybrid Mamba-2 + Attention architecture, this means LoRA only touches 4 out of 56 layers (7.1%) — the other 52 layers are Mamba SSM layers with different parameter names (in_proj,out_proj,A_log,D,dt,x_proj,z_proj).Worse, PEFT silently skips target module names that don't exist in the model. There's no warning that the configured target modules only matched a small fraction of layers. The user sees training "complete" with loss not improving, and has no idea why.
Reproduction
We ran DPO (LoRA) on
nvidia/NVIDIA-Nemotron-Nano-9B-v2with the default PEFT target modules:Results:
The Nemotron-Nano-9B-v2 has 56 layers with this hybrid pattern:
Where
M= Mamba,*= Attention. Only 4 layers are attention. The other 52 are Mamba layers with parametersin_proj,out_proj,A_log,D— none of which were targeted by LoRA.Root Cause
nemotron_htoTRANSFORMERS_MODELS_TO_LORA_TARGET_MODULES_MAPPINGwith only attention modulesnemotron_htomamba_model_typesin_check_lora_target_modules_mamba(), which forbids targeting Mamba modules (in_proj,out_proj,conv1d)Proposed Fixes
Fix 1: Warn on low coverage
When
LoraConfig.target_modulesmatches fewer than N% of linear layers in the model, emit a warning:Fix 2: Document hybrid architecture target modules
Add documentation for hybrid Mamba+Attention models showing the correct target modules:
Fix 3: Reconsider the Mamba module ban
PR #2562 banned Mamba modules from LoRA targeting due to shape issues. But
in_projandout_projare standardnn.Linearlayers — they should be LoRA-compatible. The ban should be scoped toconv1dand structured SSM parameters (A_log,D), not all Mamba modules.Environment
Related