8000 llama : assume tied weights if lm_head/output weights is missing (#5824) · hazelnutcloud/llama.cpp@e30f26b · GitHub
[go: up one dir, main page]

Skip to content

Commit e30f26b

Browse files
dmahurinhazelnutcloud
authored andcommitted
llama : assume tied weights if lm_head/output weights is missing (ggml-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>
1 parent 2aba0cb commit e30f26b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llama.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3888,7 +3888,13 @@ static bool llm_load_tensors(
38883888
{
38893889
model.output_norm = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd});
38903890
if (model.arch != LLM_ARCH_MINICPM){
3891-
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab});
3891+
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, false);
3892+
// if output is NULL, init from the input tok embed
3893+
if (model.output == NULL) {
3894+
model.output = ml.create_tensor(ctx_output, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab});
3895+
ml.n_created--; // artificial tensor
3896+
ml.size_data += ggml_nbytes(model.output);
3897+
}
38923898
}
38933899
}
38943900

0 commit comments

Comments
 (0)
0