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
5b3393b6
Commit
5b3393b6
authored
Nov 13, 2024
by
Michael Yang
Browse files
fix(mllama): sync backend between batches
parent
c2e8cbaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
llama/llama.go
llama/llama.go
+4
-0
llama/runner/runner.go
llama/runner/runner.go
+7
-0
No files found.
llama/llama.go
View file @
5b3393b6
...
@@ -598,6 +598,10 @@ func (c *Context) SetCrossAttention(state bool) {
...
@@ -598,6 +598,10 @@ func (c *Context) SetCrossAttention(state bool) {
C
.
llama_set_cross_attention
(
c
.
c
,
C
.
bool
(
state
))
C
.
llama_set_cross_attention
(
c
.
c
,
C
.
bool
(
state
))
}
}
func
(
c
*
Context
)
Synchronize
()
{
C
.
llama_synchronize
(
c
.
c
)
}
// sampling
// sampling
// TODO: this is a temporary wrapper to allow calling C++ code from CGo
// TODO: this is a temporary wrapper to allow calling C++ code from CGo
type
SamplingContext
struct
{
type
SamplingContext
struct
{
...
...
llama/runner/runner.go
View file @
5b3393b6
...
@@ -427,6 +427,13 @@ func (s *Server) processBatch(tokenBatch *llama.Batch, embedBatch *llama.Batch)
...
@@ -427,6 +427,13 @@ func (s *Server) processBatch(tokenBatch *llama.Batch, embedBatch *llama.Batch)
return
return
}
}
if
crossAttention
{
// synchronize state to ensure the cross attention batch is complete.
// needed specifically for multi-GPU systems otherwise an inflight
// task may be incorrectly invalidated causing a crash
s
.
lc
.
Synchronize
()
}
for
i
,
seq
:=
range
s
.
seqs
{
for
i
,
seq
:=
range
s
.
seqs
{
if
seq
==
nil
{
if
seq
==
nil
{
continue
continue
...
...
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