Browse Source
Merge pull request #5117 from dhiltgen/fix_prediction
Handle models with divergent layer sizes
royh-params
Daniel Hiltgen
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
0 deletions
-
llm/memory.go
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package llm |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"log/slog" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
@ -179,6 +180,11 @@ func EstimateGPULayers(gpus []gpu.GpuInfo, ggml *GGML, projectors []string, opts |
|
|
|
|
|
|
|
// For all the layers, find where they can fit on the GPU(s)
|
|
|
|
for i := range int(ggml.KV().BlockCount()) { |
|
|
|
// Some models have inconsistent layer sizes
|
|
|
|
if blk, ok := layers[fmt.Sprintf("blk.%d", i)]; ok { |
|
|
|
layerSize = blk.size() |
|
|
|
layerSize += kv / ggml.KV().BlockCount() |
|
|
|
} |
|
|
|
memoryWeights += layerSize |
|
|
|
|
|
|
|
if opts.NumGPU >= 0 && layerCount >= opts.NumGPU { |
|
|
|
|