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
10a8e04a
Unverified
Commit
10a8e04a
authored
Jun 23, 2025
by
Daniel Hiltgen
Committed by
GitHub
Jun 23, 2025
Browse files
avoid context overflow (#11175)
For smaller context models, make sure we do not exceed the training size.
parent
1c6669e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
llm/server.go
llm/server.go
+7
-0
No files found.
llm/server.go
View file @
10a8e04a
...
@@ -139,6 +139,13 @@ func NewLlamaServer(gpus discover.GpuInfoList, modelPath string, f *ggml.GGML, a
...
@@ -139,6 +139,13 @@ func NewLlamaServer(gpus discover.GpuInfoList, modelPath string, f *ggml.GGML, a
gpus
=
discover
.
GetCPUInfo
()
gpus
=
discover
.
GetCPUInfo
()
}
}
// Verify the requested context size is <= the model training size
trainCtx
:=
f
.
KV
()
.
ContextLength
()
if
opts
.
NumCtx
/
numParallel
>
int
(
trainCtx
)
&&
trainCtx
>
0
{
slog
.
Warn
(
"requested context size too large for model"
,
"num_ctx"
,
opts
.
NumCtx
,
"num_parallel"
,
numParallel
,
"n_ctx_train"
,
trainCtx
)
opts
.
NumCtx
=
int
(
trainCtx
)
*
numParallel
}
estimate
:=
EstimateGPULayers
(
gpus
,
f
,
projectors
,
opts
,
numParallel
)
estimate
:=
EstimateGPULayers
(
gpus
,
f
,
projectors
,
opts
,
numParallel
)
if
len
(
gpus
)
>
1
||
gpus
[
0
]
.
Library
!=
"cpu"
{
if
len
(
gpus
)
>
1
||
gpus
[
0
]
.
Library
!=
"cpu"
{
switch
{
switch
{
...
...
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