Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
5a41d69b
Unverified
Commit
5a41d69b
authored
Dec 07, 2025
by
Jeffrey Morgan
Committed by
GitHub
Dec 07, 2025
Browse files
fs/ggml: write int32 and int64 values to gguf files (#13335)
parent
c146a138
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
fs/ggml/gguf.go
fs/ggml/gguf.go
+8
-0
fs/ggml/gguf_test.go
fs/ggml/gguf_test.go
+11
-3
No files found.
fs/ggml/gguf.go
View file @
5a41d69b
...
...
@@ -597,6 +597,10 @@ func ggufWriteKV(ws io.WriteSeeker, arch, k string, v any) error {
var
err
error
switch
v
:=
v
.
(
type
)
{
case
int32
:
err
=
writeGGUF
(
ws
,
ggufTypeInt32
,
v
)
case
int64
:
err
=
writeGGUF
(
ws
,
ggufTypeInt64
,
v
)
case
uint32
,
FileType
:
err
=
writeGGUF
(
ws
,
ggufTypeUint32
,
v
)
case
uint64
:
...
...
@@ -611,6 +615,10 @@ func ggufWriteKV(ws io.WriteSeeker, arch, k string, v any) error {
err
=
writeGGUFArray
(
ws
,
ggufTypeInt32
,
v
)
case
*
array
[
int32
]
:
err
=
writeGGUFArray
(
ws
,
ggufTypeInt32
,
v
.
values
)
case
[]
int64
:
err
=
writeGGUFArray
(
ws
,
ggufTypeInt64
,
v
)
case
*
array
[
int64
]
:
err
=
writeGGUFArray
(
ws
,
ggufTypeInt64
,
v
.
values
)
case
[]
uint32
:
err
=
writeGGUFArray
(
ws
,
ggufTypeUint32
,
v
)
case
*
array
[
uint32
]
:
...
...
fs/ggml/gguf_test.go
View file @
5a41d69b
...
...
@@ -42,6 +42,10 @@ func TestWriteGGUF(t *testing.T) {
"general.architecture"
:
"test"
,
"general.alignment"
:
uint32
(
16
),
"test.key"
:
"value"
,
"test.int32_key"
:
int32
(
-
42
),
"test.int64_key"
:
int64
(
-
9223372036854775808
),
"test.int32_array"
:
[]
int32
{
-
1
,
0
,
1
,
2147483647
,
-
2147483648
},
"test.int64_array"
:
[]
int64
{
-
1
,
0
,
1
,
9223372036854775807
,
-
9223372036854775808
},
"attention.key"
:
"value2"
,
"tokenizer.key"
:
"value3"
,
"adapter.key"
:
"value4"
,
...
...
@@ -55,7 +59,7 @@ func TestWriteGGUF(t *testing.T) {
}
defer
r
.
Close
()
ff
,
err
:=
Decode
(
r
,
0
)
ff
,
err
:=
Decode
(
r
,
-
1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -65,15 +69,19 @@ func TestWriteGGUF(t *testing.T) {
"general.alignment"
:
uint32
(
16
),
"general.parameter_count"
:
uint64
(
54
),
"test.key"
:
"value"
,
"test.int32_key"
:
int32
(
-
42
),
"test.int64_key"
:
int64
(
-
9223372036854775808
),
"test.int32_array"
:
&
array
[
int32
]{
size
:
5
,
values
:
[]
int32
{
-
1
,
0
,
1
,
2147483647
,
-
2147483648
}},
"test.int64_array"
:
&
array
[
int64
]{
size
:
5
,
values
:
[]
int64
{
-
1
,
0
,
1
,
9223372036854775807
,
-
9223372036854775808
}},
"test.attention.key"
:
"value2"
,
"tokenizer.key"
:
"value3"
,
"adapter.key"
:
"value4"
,
},
ff
.
KV
());
diff
!=
""
{
},
ff
.
KV
()
,
cmp
.
AllowUnexported
(
array
[
int32
]{},
array
[
int64
]{})
);
diff
!=
""
{
t
.
Errorf
(
"Mismatch (-want +got):
\n
%s"
,
diff
)
}
if
diff
:=
cmp
.
Diff
(
Tensors
{
Offset
:
800
,
Offset
:
992
,
items
:
[]
*
Tensor
{
{
Name
:
"blk.0.attn_k.weight"
,
Offset
:
0
,
Shape
:
[]
uint64
{
2
,
3
}},
{
Name
:
"blk.0.attn_norm.weight"
,
Offset
:
32
,
Shape
:
[]
uint64
{
2
,
3
}},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment