Skip to content

llama : add support for GPT2, Bloom and CodeShell tied word embeddings - #12456

Merged
ngxson merged 5 commits into
ggml-org:masterfrom
CISC:tied-word-embeddings
Mar 19, 2025
Merged

llama : add support for GPT2, Bloom and CodeShell tied word embeddings#12456
ngxson merged 5 commits into
ggml-org:masterfrom
CISC:tied-word-embeddings

Conversation

@CISC

@CISC CISC commented Mar 18, 2025

Copy link
Copy Markdown
Member

Also remove weight duplication from said models on conversion.

I've converted and tested the following models, confirming that they do not initially have output weights (except for CodeShell, see below) but rely on word embeddings and output weights being tied together at runtime:

  • openai-community/gpt2
  • bigscience/bloomz-560m
  • WisdomShell/CodeShell-7B-Chat
  • WisdomShell/Shell-7B-Chat

For some reason CodeShell has inverted ties; output weights are provided in the bin/safetensors, but not word embeddings, even though our conversion code seems to imply otherwise.

Added a workaround for transformer.wte.weight being in the CodeShell weight map even though it's not in the tensor file(s), causing a conversion error unless you edit the .index.json file.

@CISC
CISC requested a review from ngxson March 18, 2025 19:48
@github-actions github-actions Bot added the python python script changes label Mar 18, 2025
CISC added 3 commits March 18, 2025 23:44
It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.
@ngxson
ngxson merged commit 108e53c into ggml-org:master Mar 19, 2025
@CISC
CISC deleted the tied-word-embeddings branch March 19, 2025 08:09
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
ggml-org#12456)

* Add support for GPT2, Bloom and CodeShell tied word embeddings

* Deduplicate tied word embeddings weights

* Workaround for incorrect weight map

It appears transformer.wte.weight is in the weight map even though the weights are not there, remove it if output weights are encountered first.

* check++

* fatfingers--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python python script changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants