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
8c238e70
Commit
8c238e70
authored
Oct 31, 2024
by
Michael Yang
Browse files
mllama cross attention
parent
16f4eabe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
llm/ggml.go
llm/ggml.go
+24
-0
No files found.
llm/ggml.go
View file @
8c238e70
...
@@ -400,6 +400,30 @@ func (llm GGML) GraphSize(context, batch uint64) (partialOffload, fullOffload ui
...
@@ -400,6 +400,30 @@ func (llm GGML) GraphSize(context, batch uint64) (partialOffload, fullOffload ui
4
*
batch
*
(
1
+
2
*
embedding
+
context
*
(
1
+
heads
))
+
embedding
*
(
6
*
context
*
headsKV
/
heads
+
embedding
*
9
/
16
),
4
*
batch
*
(
1
+
2
*
embedding
+
context
*
(
1
+
heads
))
+
embedding
*
(
6
*
context
*
headsKV
/
heads
+
embedding
*
9
/
16
),
)
)
}
}
case
"mllama"
:
var
visionTokens
,
tiles
uint64
=
1601
,
4
fullOffload
=
max
(
4
*
batch
*
(
2
+
3
*
embedding
+
embeddingHeadsK
*
heads
+
context
*
(
1
+
heads
)),
// vocab graph
4
*
batch
*
(
embedding
+
vocab
),
)
var
ropeFreqsCount
uint64
if
ropeFreqs
,
ok
:=
llm
.
Tensors
()
.
Layers
()[
"rope_freqs"
];
ok
{
if
ropeFreqsWeights
,
ok
:=
ropeFreqs
[
"weights"
];
ok
{
ropeFreqsCount
=
ropeFreqsWeights
.
parameters
()
}
}
partialOffload
=
max
(
4
*
(
batch
*
(
2
*
embedding
+
1
+
context
*
(
1
+
heads
)
+
embeddingHeadsK
*
heads
)
+
ropeFreqsCount
+
embeddingHeadsK
*
context
*
headsKV
),
// vocab graph
4
*
batch
*
(
embedding
+
vocab
)
+
embedding
*
vocab
*
105
/
128
,
)
case
"gemma"
,
"gemma2"
:
case
"gemma"
,
"gemma2"
:
fullOffload
=
max
(
fullOffload
=
max
(
4
*
batch
*
(
embedding
+
vocab
),
4
*
batch
*
(
embedding
+
vocab
),
...
...
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