This commit is contained in:
Josh Yan 2024-07-16 16:40:38 -07:00
parent dea2204b82
commit 64405525b4
2 changed files with 2 additions and 5 deletions

View File

@ -252,8 +252,7 @@ func (llm *gguf) Decode(rs io.ReadSeeker) error {
return fmt.Errorf("failed to get current offset: %w", err)
}
// ADD PADDING
// align to next 32-byte boundary
llm.offset = offset + llm.padding(offset, int64(alignment))
for _, tensor := range llm.tensors {

View File

@ -260,7 +260,6 @@ func parseFromFile(ctx context.Context, file *os.File, digest string, fn func(ap
Shape: shape,
WriterTo: &llm.TensorWriter{
// This needs offset + tensors.Offset int64(tensor.Offset) to be correct
Reader: io.NewSectionReader(file, offset+ggmlTensors.Offset+int64(tensor.Offset), int64(tensor.Size())),
},
})
@ -268,10 +267,9 @@ func parseFromFile(ctx context.Context, file *os.File, digest string, fn func(ap
reader = &llm.GGUFWriter{
KV: ggml.KV(),
// Update .Tensors
Tensors: llm.Tensors{
Items: tensors,
Offset: ggml.Tensors().Offset,
Offset: ggmlTensors.Offset,
},
}
}