Browse Source
avoid context overflow (#11175)
For smaller context models, make sure we do not exceed the training size.
mxyng/cleanup
v0.9.3-rc0
Daniel Hiltgen
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
7 additions and
0 deletions
-
llm/server.go
|
|
@ -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 { |
|
|
|