Skip to content

Commit

Permalink
Don't show warning for inv_freq buffers (#35255)
Browse files Browse the repository at this point in the history
dont show warning
  • Loading branch information
zucchini-nlp authored Jan 9, 2025
1 parent 8cad65a commit 137965c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4479,6 +4479,11 @@ def _load_pretrained_model(
model_buffers = {".".join([prefix, key]) for key in model_buffers}
unexpected_keys = sorted(unexpected_keys - model_buffers)

# Clean up buffer for `inv-freq` because RoPE embedding moved under base model (https://github.com/huggingface/transformers/pull/34858)
has_inv_freq_buffers = any(buffer.endswith("rotary_emb.inv_freq") for buffer in model_buffers)
if has_inv_freq_buffers:
unexpected_keys = {k for k in unexpected_keys if "rotary_emb.inv_freq" not in k}

model.tie_weights()
if device_map is None and not is_fsdp_enabled() and not is_deepspeed_zero3_enabled():
ptrs = collections.defaultdict(list)
Expand Down

0 comments on commit 137965c

Please sign in to comment.