Skip to content

Commit e11b2e6

Browse files
authored
Qwen2 : assume tied weights if lm_head/output weights is missing (#6738)
1 parent c71bfd7 commit e11b2e6

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
@@ -5184,7 +5184,13 @@ static bool llm_load_tensors(
51845184
// output
51855185
{
51865186
model.output_norm = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd});
5187-
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab});
5187+
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, false);
5188+
// if output is NULL, init from the input tok embed
5189+
if (model.output == NULL) {
5190+
model.output = ml.create_tensor(ctx_output, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab});
5191+
ml.n_created--; // artificial tensor
5192+
ml.size_data += ggml_nbytes(model.output);
5193+
}
51885194
}
51895195

51905196
for (int i = 0; i < n_layer; ++i) {

0 commit comments

Comments
 (0)