Skip to content

FIX: AutoPeftModels never reduce embedding size#2427

Merged
BenjaminBossan merged 1 commit intohuggingface:mainfrom
BenjaminBossan:fix-autopeftmodel-dont-reduce-embedding-size
Mar 14, 2025
Merged

FIX: AutoPeftModels never reduce embedding size#2427
BenjaminBossan merged 1 commit intohuggingface:mainfrom
BenjaminBossan:fix-autopeftmodel-dont-reduce-embedding-size

Conversation

@BenjaminBossan
Copy link
Member

Resolves #2415

There was a bug in AutoPeftModels where the embedding was always resized to the vocab size of the tokenizer when the tokenizer was found. This makes sense if the vocabulary was extended, but some models like Qwen already start out with "spare" embeddings, i.e. the embedding size is larger than the vocab size. This could result in the embedding being shrunk, which in turn resulted in an error when loading the weights.

Resolves huggingface#2415

There was a bug in AutoPeftModels where the embedding was always resized
to the vocab size of the tokenizer when the tokenizer was found. This
makes sense if the vocabulary was extended, but some models like Qwen
already start out with "spare" embeddings, i.e. the embedding size is
larger than the vocab size. This could result in the embedding being
shrunk, which in turn resulted in an error when loading the weights.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@BenjaminBossan
Copy link
Member Author

MacOS errors are unrelated and seem to stem from this accelerate PR: huggingface/accelerate#3420.

@BenjaminBossan BenjaminBossan merged commit 7320bb9 into huggingface:main Mar 14, 2025
9 of 14 checks passed
@BenjaminBossan BenjaminBossan deleted the fix-autopeftmodel-dont-reduce-embedding-size branch March 14, 2025 13:17
Guy-Bilitski pushed a commit to Guy-Bilitski/peft that referenced this pull request May 13, 2025
Resolves huggingface#2415

There was a bug in AutoPeftModels where the embedding was always resized
to the vocab size of the tokenizer when the tokenizer was found. This
makes sense if the vocabulary was extended, but some models like Qwen
already start out with "spare" embeddings, i.e. the embedding size is
larger than the vocab size. This could result in the embedding being
shrunk, which in turn resulted in an error when loading the weights.
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.

size mismatch for lm_head when fintune QWEN2.5

3 participants