ggml: fix cannot read split info
This commit is contained in:
parent
efdd9b76da
commit
fb7c89801e
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"maps"
|
"maps"
|
||||||
"math"
|
"math"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ollama/ollama/format"
|
"github.com/ollama/ollama/format"
|
||||||
|
|
@ -36,8 +35,8 @@ type MetaGGML struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GGUFSplitInfo struct {
|
type GGUFSplitInfo struct {
|
||||||
no uint32
|
No uint16
|
||||||
count uint32
|
Count uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
type KV map[string]any
|
type KV map[string]any
|
||||||
|
|
@ -64,13 +63,14 @@ func (kv KV) FileType() FileType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kv KV) GGUFSplitInfo() *GGUFSplitInfo {
|
func (kv KV) GGUFSplitInfo() *GGUFSplitInfo {
|
||||||
no := kv.Uint("split.no", 0xffffffff)
|
no, found := keyValue(kv, "split.no", uint16(0))
|
||||||
if no == 0xffffffff {
|
if !found {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
count, _ := keyValue(kv, "split.count", uint16(0))
|
||||||
return &GGUFSplitInfo{
|
return &GGUFSplitInfo{
|
||||||
no: no,
|
No: no,
|
||||||
count: kv.Uint("split.count"),
|
Count: count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -642,16 +642,16 @@ func MakeMetaGGML(ggmls []GGML, ggmlPaths []string) MetaGGML {
|
||||||
type wrapper struct {
|
type wrapper struct {
|
||||||
ggml GGML
|
ggml GGML
|
||||||
path string
|
path string
|
||||||
weight int64
|
weight int
|
||||||
}
|
}
|
||||||
var wrappers []wrapper
|
var wrappers []wrapper
|
||||||
for i := range ggmls {
|
for i := range ggmls {
|
||||||
iSplitInfo := ggmls[i].KV().GGUFSplitInfo()
|
iSplitInfo := ggmls[i].KV().GGUFSplitInfo()
|
||||||
var weight int64 = 0
|
var weight int = 0
|
||||||
if iSplitInfo == nil {
|
if iSplitInfo == nil {
|
||||||
weight = -1
|
weight = -1
|
||||||
} else {
|
} else {
|
||||||
weight = int64((*iSplitInfo).no)
|
weight = int((*iSplitInfo).No)
|
||||||
}
|
}
|
||||||
wrappers = append(wrappers, wrapper{
|
wrappers = append(wrappers, wrapper{
|
||||||
ggml: ggmls[i],
|
ggml: ggmls[i],
|
||||||
|
|
@ -659,8 +659,8 @@ func MakeMetaGGML(ggmls []GGML, ggmlPaths []string) MetaGGML {
|
||||||
weight: weight,
|
weight: weight,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
sort.SliceStable(wrappers, func(i, j int) bool {
|
slices.SortStableFunc(wrappers, func(a, b wrapper) int {
|
||||||
return wrappers[i].weight < wrappers[j].weight
|
return cmp.Compare(a.weight, b.weight)
|
||||||
})
|
})
|
||||||
metaGgml := MetaGGML{}
|
metaGgml := MetaGGML{}
|
||||||
for i := range wrappers {
|
for i := range wrappers {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue