Skip to content

Assume tied weights if lm_head/output weights is missing.#5824

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
dmahurin:tied-weights
Mar 8, 2024
Merged

Assume tied weights if lm_head/output weights is missing.#5824
ggerganov merged 1 commit into
ggml-org:masterfrom
dmahurin:tied-weights

Conversation

@dmahurin

@dmahurin dmahurin commented Mar 1, 2024

Copy link
Copy Markdown
Contributor

This supports model configurations with "tie_word_embeddings", by using the embd_tokens weights if output/lm_head weights are missing (as they will be when weights are tied).

With this change, a tied model like the following can be converted to gguf.
https://huggingface.co/BEE-spoke-data/smol_llama-81M-tied

@cebtenzzre

Copy link
Copy Markdown
Collaborator

This change conflicts with the move towards only duplicating the tensors in memory at GGUF load time. See #4978, #5631, #5650, and #5670. I would prefer if we did something similar for Llama.

@dmahurin

dmahurin commented Mar 2, 2024

Copy link
Copy Markdown
Contributor Author

@cebtenzzre . Great, I did not see those changes, and this change was intended to be a quick work-around until tied-weights are more properly supported, which sounds like is happening. I will look at those changes.

This is to support model configurations with "tie_word_embeddings" set to true.
@dmahurin

dmahurin commented Mar 2, 2024

Copy link
Copy Markdown
Contributor Author

@cebtenzzre, Change updated in llama.cpp, with LLAMA tied-weights now being similar to other tied-weights.

@ggerganov ggerganov merged commit e457fb3 into ggml-org:master Mar 8, 2024
@dmahurin dmahurin deleted the tied-weights branch March 8, 2024 13:38
hazelnutcloud pushed a commit to hazelnutcloud/llama.cpp that referenced this pull request Mar 10, 2024
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
NeoZhangJianyu pushed a commit to NeoZhangJianyu/llama.cpp that referenced this pull request Mar 12, 2024
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…l-org#5824)

This is to support model configurations with "tie_word_embeddings" set to true.

Co-authored-by: Don Mahurin <2797413+dmahurin@users.noreply.github.com>
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.

3 participants