Skip to content

fix: update weight initialization method in LinearLoRA class#896

Merged
hemildesai merged 1 commit intomainfrom
ruit/lora_init
Nov 27, 2025
Merged

fix: update weight initialization method in LinearLoRA class#896
hemildesai merged 1 commit intomainfrom
ruit/lora_init

Conversation

@RayenTian
Copy link
Copy Markdown
Contributor

Summary

This PR fixes an incorrect weight initialization method in the LinearLoRA class. The xavier initialization was incorrectly using torch.nn.init.uniform_() instead of the proper xavier_normal_() function.

Problem

In the LinearLoRA class located in nemo_automodel/components/_peft/lora.py, when init_method="xavier" is specified, the code was using a generic uniform distribution initialization instead of the Xavier initialization method. This semantic mismatch could lead to suboptimal initialization and potentially affect model convergence and fine-tuning performance.

Solution

File: nemo_automodel/components/_peft/lora.py

Changed the initialization of lora_A weights from:

torch.nn.init.uniform_(self.lora_A.weight.data)

To the correct Xavier initialization:

nn.init.xavier_normal_(self.lora_A.weight.data)

Impact

  • Affects: LoRA weight initialization when using xavier method
  • Scope: Models using LoRA fine-tuning with xavier initialization
  • Behavior Change: The initialization distribution will now follow the Xavier/Glorot normal distribution instead of a simple uniform distribution, which is the expected behavior for xavier initialization

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Nov 27, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@RayenTian RayenTian requested a review from joyang-nv November 27, 2025 13:32
@hemildesai
Copy link
Copy Markdown
Contributor

/ok to test 7ae52ac

@hemildesai hemildesai merged commit 2d20e33 into main Nov 27, 2025
58 checks passed
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.

2 participants