Skip to content

Commit 8039a27

Browse files
committed
fix peft
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
1 parent 05ba487 commit 8039a27

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nemo_automodel/components/checkpoint/checkpointing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,10 @@ def _do_save(
635635
# PEFT saving is done on rank0 so it is a special case
636636
if self.config.is_peft and is_model:
637637
if not torch.distributed.is_initialized() or torch.distributed.get_rank() == 0:
638-
save_file(state_dict, os.path.join(path, "adapter_model.safetensors"))
638+
# Materialize lazy mappings (e.g. LazyHFStateDict) into a plain
639+
# dict because safetensors.save_file only accepts dict.
640+
sd = dict(state_dict) if not isinstance(state_dict, dict) else state_dict
641+
save_file(sd, os.path.join(path, "adapter_model.safetensors"))
639642
if torch.distributed.is_initialized():
640643
torch.distributed.barrier()
641644
return

0 commit comments

Comments
 (0)