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
00b0699c
Unverified
Commit
00b0699c
authored
Apr 25, 2024
by
Jeffrey Morgan
Committed by
GitHub
Apr 25, 2024
Browse files
Reload model if `num_gpu` changes (#3920)
* reload model if `num_gpu` changes * dont reload on -1 * fix tests
parent
993cf8bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
server/sched.go
server/sched.go
+12
-6
server/sched_test.go
server/sched_test.go
+3
-0
No files found.
server/sched.go
View file @
00b0699c
...
@@ -421,16 +421,21 @@ func (runner *runnerRef) needsReload(ctx context.Context, req *LlmRequest) bool
...
@@ -421,16 +421,21 @@ func (runner *runnerRef) needsReload(ctx context.Context, req *LlmRequest) bool
slog
.
Debug
(
"evaluating already loaded"
,
"model"
,
req
.
model
.
ModelPath
)
slog
.
Debug
(
"evaluating already loaded"
,
"model"
,
req
.
model
.
ModelPath
)
runner
.
refMu
.
Lock
()
runner
.
refMu
.
Lock
()
defer
runner
.
refMu
.
Unlock
()
defer
runner
.
refMu
.
Unlock
()
// Ignore the NumGPU settings for comparison
optsExisting
:=
runner
.
Options
.
Runner
optsExisting
.
NumGPU
=
-
1
optsNew
:=
req
.
opts
.
Runner
optsNew
.
NumGPU
=
-
1
timeout
:=
10
*
time
.
Second
timeout
:=
10
*
time
.
Second
if
runner
.
loading
{
if
runner
.
loading
{
timeout
=
2
*
time
.
Minute
// Initial load can take a long time for big models on slow systems...
timeout
=
2
*
time
.
Minute
// Initial load can take a long time for big models on slow systems...
}
}
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
timeout
)
// BUG -
// Don't reload runner if num_gpu=-1 was provided
optsExisting
:=
runner
.
Options
.
Runner
optsNew
:=
req
.
opts
.
Runner
if
optsNew
.
NumGPU
<
0
{
optsExisting
.
NumGPU
=
-
1
optsNew
.
NumGPU
=
-
1
}
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
timeout
)
defer
cancel
()
defer
cancel
()
if
!
reflect
.
DeepEqual
(
runner
.
adapters
,
req
.
model
.
AdapterPaths
)
||
// have the adapters changed?
if
!
reflect
.
DeepEqual
(
runner
.
adapters
,
req
.
model
.
AdapterPaths
)
||
// have the adapters changed?
!
reflect
.
DeepEqual
(
runner
.
projectors
,
req
.
model
.
ProjectorPaths
)
||
// have the projectors changed?
!
reflect
.
DeepEqual
(
runner
.
projectors
,
req
.
model
.
ProjectorPaths
)
||
// have the projectors changed?
...
@@ -438,6 +443,7 @@ func (runner *runnerRef) needsReload(ctx context.Context, req *LlmRequest) bool
...
@@ -438,6 +443,7 @@ func (runner *runnerRef) needsReload(ctx context.Context, req *LlmRequest) bool
runner
.
llama
.
Ping
(
ctx
)
!=
nil
{
runner
.
llama
.
Ping
(
ctx
)
!=
nil
{
return
true
return
true
}
}
return
false
return
false
}
}
...
...
server/sched_test.go
View file @
00b0699c
...
@@ -490,6 +490,9 @@ func TestNeedsReload(t *testing.T) {
...
@@ -490,6 +490,9 @@ func TestNeedsReload(t *testing.T) {
require
.
False
(
t
,
resp
)
require
.
False
(
t
,
resp
)
req
.
opts
.
NumGPU
=
99
req
.
opts
.
NumGPU
=
99
resp
=
runner
.
needsReload
(
ctx
,
req
)
resp
=
runner
.
needsReload
(
ctx
,
req
)
require
.
True
(
t
,
resp
)
req
.
opts
.
NumGPU
=
-
1
resp
=
runner
.
needsReload
(
ctx
,
req
)
require
.
False
(
t
,
resp
)
require
.
False
(
t
,
resp
)
}
}
...
...
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