@@ -540,6 +540,7 @@ static const std::map<llm_arch, std::map<llm_tensor, std::string>> LLM_TENSOR_NA
540
540
{
541
541
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
542
542
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
543
+ { LLM_TENSOR_OUTPUT, "output"},
543
544
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
544
545
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
545
546
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
@@ -4300,9 +4301,9 @@ static bool llm_load_tensors(
4300
4301
{
4301
4302
model.output_norm = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd});
4302
4303
model.output_norm_b = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "bias"), {n_embd});
4303
- if (gguf_find_tensor(ml.ctx_gguf, tn(LLM_TENSOR_OUTPUT, "weight").c_str()) >= 0) {
4304
- model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab});
4305
- } else {
4304
+
4305
+ model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, false );
4306
+ if (!model.output) {
4306
4307
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab}); // needs to be on GPU
4307
4308
ml.n_created--; // artificial tensor
4308
4309
ml.size_data += ggml_nbytes(model.output);
@@ -4507,10 +4508,12 @@ static bool llm_load_tensors(
4507
4508
model.output_norm = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd});
4508
4509
model.output_norm_b = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "bias"), {n_embd}, false);
4509
4510
4510
- // same as tok_embd, duplicated to allow offloading
4511
- model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab});
4512
- ml.n_created--; // artificial tensor
4513
- ml.size_data += ggml_nbytes(model.output);
4511
+ model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, false);
4512
+ if (!model.output) {
4513
+ model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab}); // needs to be on GPU
4514
+ ml.n_created--; // artificial tensor
4515
+ ml.size_data += ggml_nbytes(model.output);
4516
+ }
4514
4517
}
4515
4518
4516
4519
for (int i = 0; i < n_layer; ++i) {
0 commit comments