Skip to content

Commit

Permalink
Merge pull request huggingface#140 from zanussbaum/zero_init
Browse files Browse the repository at this point in the history
fix: count params when zero init'd
  • Loading branch information
pacman100 authored Feb 27, 2023
2 parents 681ce93 + e6bf09d commit aa18556
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/peft/peft_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ def print_trainable_parameters(self):
trainable_params = 0
all_param = 0
for _, param in self.named_parameters():
all_param += param.numel()
num_params = param.numel()
# if using DS Zero 3 and the weights are initialized empty
if num_params == 0 and hasattr(param, "ds_numel"):
num_params = param.ds_numel

all_param += num_params
if param.requires_grad:
trainable_params += param.numel()
print(
Expand Down

0 comments on commit aa18556

Please sign in to comment.