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
a422ba39
Commit
a422ba39
authored
Mar 13, 2025
by
Michael Yang
Browse files
roughly count gemma3 graph
the largest operation is by far (q @ k) so just count that for simplicity
parent
d2ec2237
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
18 deletions
+16
-18
fs/ggml/ggml.go
fs/ggml/ggml.go
+16
-18
No files found.
fs/ggml/ggml.go
View file @
a422ba39
...
@@ -587,34 +587,32 @@ func (llm GGML) VisionGraphSize() (weights, graphSize uint64) {
...
@@ -587,34 +587,32 @@ func (llm GGML) VisionGraphSize() (weights, graphSize uint64) {
}
}
}
}
switch
llm
.
KV
()
.
Architecture
()
{
imageSize
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.image_size"
))
case
"mllama"
:
patchSize
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.patch_size"
))
kv
:=
func
(
n
string
)
uint64
{
if
v
,
ok
:=
llm
.
KV
()[
"mllama.vision."
+
n
]
.
(
uint32
);
ok
{
return
uint64
(
v
)
}
return
0
}
imageSize
:=
kv
(
"image_size"
)
numPatches
:=
(
imageSize
/
patchSize
)
*
(
imageSize
/
patchSize
)
if
_
,
ok
:=
llm
.
Tensors
()
.
GroupLayers
()[
"v"
][
"class_embd"
];
ok
{
numPatches
++
}
maxNumTiles
:=
kv
(
"max_num_tiles"
)
headCount
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.attention.head_count"
))
embeddingLength
:=
kv
(
"embedding_length"
)
headCount
:=
kv
(
"attention.head_count"
)
numPatches
:=
(
imageSize
/
kv
(
"patch_size"
))
*
(
imageSize
/
kv
(
"patch_size"
))
switch
llm
.
KV
()
.
Architecture
()
{
if
_
,
ok
:=
llm
.
Tensors
()
.
GroupLayers
()[
"v"
][
"class_embd"
];
ok
{
case
"mllama"
:
numPatches
++
}
numPaddedPatches
:=
numPatches
+
8
-
(
numPatches
%
8
)
%
8
numPaddedPatches
:=
numPatches
+
8
-
(
numPatches
%
8
)
%
8
maxNumTiles
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.max_num_tiles"
))
numChannels
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.num_channels"
))
embeddingLength
:=
uint64
(
llm
.
KV
()
.
Uint
(
"vision.embedding_length"
))
graphSize
=
4
*
(
8
+
graphSize
=
4
*
(
8
+
imageSize
*
imageSize
*
kv
(
"
num
_c
hannels
"
)
*
maxNumTiles
+
imageSize
*
imageSize
*
num
C
hannels
*
maxNumTiles
+
embeddingLength
*
numPatches
*
maxNumTiles
+
embeddingLength
*
numPatches
*
maxNumTiles
+
9
*
embeddingLength
*
numPaddedPatches
*
maxNumTiles
+
9
*
embeddingLength
*
numPaddedPatches
*
maxNumTiles
+
numPaddedPatches
*
maxNumTiles
*
numPaddedPatches
*
maxNumTiles
*
headCount
)
numPaddedPatches
*
maxNumTiles
*
numPaddedPatches
*
maxNumTiles
*
headCount
)
case
"gemma3"
:
graphSize
=
4
*
(
numPatches
*
numPatches
*
headCount
)
}
}
return
weights
,
graphSize
return
weights
,
graphSize
...
...
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