From 81d55d3e4d3e18404414900dd341438aad329656 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Mon, 18 Nov 2024 11:48:13 -0800 Subject: [PATCH] fix index out of range on zero layer metal load (#7696) If the model doesn't fit any layers on metal, and we load zero layers we would panic trying to look up the GPU size during scheduling ops --- llm/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llm/server.go b/llm/server.go index 96815826..624acbf8 100644 --- a/llm/server.go +++ b/llm/server.go @@ -1092,7 +1092,9 @@ func (s *llmServer) EstimatedTotal() uint64 { func (s *llmServer) EstimatedVRAMByGPU(gpuID string) uint64 { for i, gpu := range s.gpus { if gpu.ID == gpuID { - return s.estimate.GPUSizes[i] + if i < len(s.estimate.GPUSizes) { + return s.estimate.GPUSizes[i] + } } } return 0