Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ def build_net(self):
with misc.timer("Creating PyTorch model"):
with torch.device(init_device):
net = lazy_instantiate(config.net)
if config.use_lora:
self.add_lora(
net,
lora_rank=config.lora_rank,
lora_alpha=config.lora_alpha,
lora_target_modules=config.lora_target_modules,
init_lora_weights=config.init_lora_weights,
)

self._param_count = count_params(net, verbose=False)

Expand All @@ -204,6 +196,15 @@ def build_net(self):
# IMPORTANT: (qsh) model init should not depends on current tensor shape, or it can handle Dtensor shape.
net.init_weights()

if config.use_lora:
self.add_lora(

Choose a reason for hiding this comment

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

Thank you for pointing it out, I agree adding loRA after weights initialization is better to preserve (random A, zero B) metrices. We will add the change in the code.

net,
lora_rank=config.lora_rank,
lora_alpha=config.lora_alpha,
lora_target_modules=config.lora_target_modules,
init_lora_weights=config.init_lora_weights,
)

if self.fsdp_device_mesh:
broadcast_dtensor_model_states(net, self.fsdp_device_mesh)
for name, param in net.named_parameters():
Expand Down