Skip to content

Commit 11ed1fb

Browse files
committed
mpt : do not duplicate token_embd.weight on disk
Previous attempt was ggml-org#3626 (cherry picked from commit 549fe80) Signed-off-by: Jared Van Bortel <[email protected]>
1 parent cfb5f03 commit 11ed1fb

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

convert-hf-to-gguf.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,6 @@ def write_tensors(self):
618618

619619
self.gguf_writer.add_tensor(new_name, data)
620620

621-
# note: MPT output is tied to (same as) wte in original model;
622-
# for easier implementation in llama.cpp it's duplicated in GGUF, though :/
623-
if new_name == "token_embd.weight":
624-
self.gguf_writer.add_tensor("output.weight", data)
625-
626621

627622
class OrionModel(Model):
628623
def set_vocab(self):

llama.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4057,7 +4057,10 @@ static bool llm_load_tensors(
40574057
// output
40584058
{
40594059
model.output_norm = ml.create_tensor(ctx_output, tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd});
4060-
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab});
4060+
// same as tok_embd, duplicated to allow offloading
4061+
model.output = ml.create_tensor(ctx_output_split, tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab});
4062+
ml.n_created--; // artificial tensor
4063+
ml.size_data += ggml_nbytes(model.output);
40614064
}
40624065

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

0 commit comments

Comments
 (0)