Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
server: read loaded runner models without refMu (#19070)
Daniel Hiltgen52f168120e8c
diff --git a/server/routes_test.go b/server/routes_test.goindex e46398d36..c915fa3ae 100644--- a/server/routes_test.go+++ b/server/routes_test.go@@ -129,7 +129,7 @@ func TestLoadedModelLookupTracksSymlinkTag(t *testing.T) {if !manifest.NamedManifestPointsToDigest(name, initial.Digest) {t.Skip("v2 tag is a regular file on this platform or filesystem")}- s.sched.loaded["initial"] = &runnerRef{model: initial}+ s.sched.loaded["initial"] = withModel(&runnerRef{}, initial)warm, err := s.getExistingModelForRunner("WARM-MODEL", "")if err != nil || warm != initial {@@ -149,7 +149,7 @@ func TestLoadedModelLookupTracksSymlinkTag(t *testing.T) {if _, err := s.getExistingModelForRunner("warm-model", ""); err == nil {t.Fatal("cold lookup accepted a corrupt manifest blob")}- s.sched.loaded["initial"] = &runnerRef{model: initial}+ s.sched.loaded["initial"] = withModel(&runnerRef{}, initial)if err := manifest.WriteManifestData(name, []byte(`{"schemaVersion":2,"layers":[]}`)); err != nil {t.Fatal(err)}@@ -160,7 +160,7 @@ func TestLoadedModelLookupTracksSymlinkTag(t *testing.T) {if updated == initial || updated.Digest == initial.Digest {t.Fatal("repointed tag reused the old model")}- s.sched.loaded["updated"] = &runnerRef{model: updated}+ s.sched.loaded["updated"] = withModel(&runnerRef{}, updated)if current, err := s.getExistingModelForRunner("warm-model", ""); err != nil || current != updated {t.Fatalf("current tag lookup = %p, %v; want %p", current, err, updated)}@@ -185,7 +185,7 @@ func TestLoadedModelLookupConcurrent(t *testing.T) {if !manifest.NamedManifestPointsToDigest(name, cached.Digest) {t.Skip("v2 tag is a regular file on this platform or filesystem")}- s.sched.loaded["cached"] = &runnerRef{model: cached}+ s.sched.loaded["cached"] = withModel(&runnerRef{}, cached)var wg sync.WaitGroupfor range 8 {@@ -234,9 +234,9 @@ func TestLoadedModelLookupConcurrent(t *testing.T) {func TestLoadedModelLookupDoesNotWaitForUnrelatedRunner(t *testing.T) {name := model.ParseName("ready-model")ready := &Model{Name: name.String()}- loading := &runnerRef{model: &Model{Name: "loading-model"}, loading: true}+ loading := withModel(&runnerRef{loading: true}, &Model{Name: "loading-model"})s := &Scheduler{loaded: map[string]*runnerRef{- "ready": {model: ready},+ "ready": withModel(&runnerRef{}, ready),"loading": loading,}}@@ -352,7 +352,7 @@ func TestLoadedModelLookupVerifiesRegularManifest(t *testing.T) {if err != nil {t.Fatal(err)}- s.sched.loaded["initial"] = &runnerRef{model: initial}+ s.sched.loaded["initial"] = withModel(&runnerRef{}, initial)path, err := manifest.V2PathForName(name)if err != nil {@@ -405,8 +405,8 @@ func TestLoadedModelLookupRunnerSelection(t *testing.T) {defaultModel := &Model{Name: name.String(), Runner: manifest.RunnerMLX}explicitModel := &Model{Name: name.String(), Runner: manifest.RunnerGGML, runnerSelection: manifest.RunnerGGML}s := &Scheduler{loaded: map[string]*runnerRef{- "default": {model: defaultModel},- "explicit": {model: explicitModel},+ "default": withModel(&runnerRef{}, defaultModel),+ "explicit": withModel(&runnerRef{}, explicitModel),}}if got := s.loadedModelsForName(name, manifest.RunnerGGML); len(got) != 1 || got[0] != explicitModel {t.Fatalf("explicit runner lookup = %v; want GGML model", got)@@ -420,7 +420,7 @@ func TestLoadedModelLookupRunnerSelection(t *testing.T) {topRunner = manifest.RunnerMLX}topModel := &Model{Name: name.String(), Runner: topRunner, runnerSelection: topRunner}- s.loaded = map[string]*runnerRef{"top": {model: topModel}}+ s.loaded = map[string]*runnerRef{"top": withModel(&runnerRef{}, topModel)}if got := s.loadedModelsForName(name, ""); len(got) != 1 || got[0] != topModel {t.Fatalf("default lookup after explicit preferred runner = %v; want loaded model", got)}@@ -429,7 +429,7 @@ func TestLoadedModelLookupRunnerSelection(t *testing.T) {Name: name.String(), Runner: manifest.RunnerGGML,Digest: "single-digest", ManifestDigest: "single-digest", runnerSelection: manifest.RunnerGGML,}- s.loaded = map[string]*runnerRef{"single": {model: singleManifest}}+ s.loaded = map[string]*runnerRef{"single": withModel(&runnerRef{}, singleManifest)}if got := s.loadedModelsForName(name, ""); len(got) != 1 || got[0] != singleManifest {t.Fatalf("default lookup after explicit single-manifest runner = %v; want loaded model", got)}@@ -457,7 +457,7 @@ func TestLoadedExplicitRunnerDoesNotChangeDefaultSelection(t *testing.T) {if err != nil {t.Fatal(err)}- s.sched.loaded["explicit"] = &runnerRef{model: explicit}+ s.sched.loaded["explicit"] = withModel(&runnerRef{}, explicit)selected, err := s.getExistingModelForRunner(name.String(), "")if err != nil {@@ -529,7 +529,7 @@ func BenchmarkModelLookup(b *testing.B) {b.Skip("v2 tag is a regular file on this platform or filesystem")}s := &Server{sched: &Scheduler{loaded: map[string]*runnerRef{- "cached": {model: cached},+ "cached": withModel(&runnerRef{}, cached),}}}b.ReportAllocs()for b.Loop() {@@ -549,22 +549,21 @@ func TestPsHandlerUsesRunningManifestAndRunner(t *testing.T) {s := Server{sched: &Scheduler{loaded: map[string]*runnerRef{- "test": {- model: &Model{- ShortName: "test-model:latest",- Digest: strings.Repeat("b", 64),- ManifestDigest: childDigest,- Runner: manifest.RunnerMLX,- Config: model.ConfigV2{- ModelFormat: manifest.FormatSafetensors,- },- },+ "test": withModel(&runnerRef{runner: manifest.RunnerMLX,totalSize: 1024,vramSize: 1024,expiresAt: time.Now().Add(time.Hour),sessionDuration: time.Hour,- },+ }, &Model{+ ShortName: "test-model:latest",+ Digest: strings.Repeat("b", 64),+ ManifestDigest: childDigest,+ Runner: manifest.RunnerMLX,+ Config: model.ConfigV2{+ ModelFormat: manifest.FormatSafetensors,+ },+ }),},},}diff --git a/server/sched.go b/server/sched.goindex 2f08c0951..2c8d818d1 100644--- a/server/sched.go+++ b/server/sched.go@@ -13,6 +13,7 @@ import ("sort""strings""sync"+ "sync/atomic""time""github.com/ollama/ollama/api"@@ -95,14 +96,7 @@ func (s *Scheduler) loadedModelsForName(name model.Name, requestedRunner string)var models []*Modelfor _, runner := range runners {- // A loading runner holds refMu until it is ready. Do not make lookup- // for another model wait for that startup; a miss falls back to a- // verified manifest lookup. Keep refMu separate from loadedMu.- if !runner.refMu.TryLock() {- continue- }- m := runner.model- runner.refMu.Unlock()+ m := runner.model.Load()if m == nil || !model.ParseName(m.Name).EqualFold(name) {continue}@@ -753,7 +747,6 @@ iGPUScan:runnerName = manifest.RunnerLlamaCPP}runner := &runnerRef{- model: req.model,modelPath: req.model.ModelPath,modelKey: schedulerModelKey(req.model),llama: llama,@@ -772,6 +765,7 @@ iGPUScan:contextShift: req.contextShift,trainContext: trainContext,}+ runner.model.Store(req.model)runner.numParallel = numParallelrunner.refMu.Lock() // hold lock until running or aborted@@ -1322,7 +1316,7 @@ func (s *Scheduler) loadedMmapModelSizeLocked() uint64 {if !runnerUsesMmap(r) {continue}- if size := modelFileSize(r.model.modelPaths()...); size > 0 {+ if size := modelFileSize(r.model.Load().modelPaths()...); size > 0 {total += size} else {total += r.totalSize@@ -1398,7 +1392,8 @@ type runnerRef struct {expireTimer *time.TimerexpiresAt time.Time- model *Model+ // model is atomic so lookups can read it without contending on refMu.+ model atomic.Pointer[Model]modelPath stringmodelKey stringnumParallel int@@ -1419,7 +1414,7 @@ func (runner *runnerRef) unload() {if runner.llama != nil {runner.llama.Close()}- runner.model = nil+ runner.model.Store(nil)runner.Options = nilrunner.gpus = nilrunner.contextShift = false@@ -1467,9 +1462,11 @@ func (runner *runnerRef) needsReload(ctx context.Context, req *LlmRequest) boolctx, cancel := context.WithTimeout(ctx, timeout)defer cancel()- if !reflect.DeepEqual(runner.model.AdapterPaths, req.model.AdapterPaths) || // have the adapters changed?- !reflect.DeepEqual(runner.model.ProjectorPaths, req.model.ProjectorPaths) || // have the projectors changed?- (!runner.model.IsMLX() && !reflect.DeepEqual(optsExisting, optsNew)) || // have the runner options changed?+ loaded := runner.model.Load()+ if loaded == nil ||+ !reflect.DeepEqual(loaded.AdapterPaths, req.model.AdapterPaths) || // have the adapters changed?+ !reflect.DeepEqual(loaded.ProjectorPaths, req.model.ProjectorPaths) || // have the projectors changed?+ (!loaded.IsMLX() && !reflect.DeepEqual(optsExisting, optsNew)) || // have the runner options changed?runner.llama.Ping(ctx) != nil {return true}@@ -1558,8 +1555,8 @@ func (runner *runnerRef) LogValue() slog.Value {}attrs := []slog.Attr{}if runner.refMu.TryLock() {- if runner.model != nil {- attrs = append(attrs, slog.String("name", runner.model.Name))+ if m := runner.model.Load(); m != nil {+ attrs = append(attrs, slog.String("name", m.Name))}if len(runner.gpus) > 0 {attrs = append(attrs,@@ -1772,7 +1769,7 @@ func (s *Scheduler) expireRunner(model *Model) {runners = append(runners, runner)} else if model != nil && model.Name != "" {for _, runner := range s.loaded {- if runner.model != nil && runner.model.Name == model.Name {+ if m := runner.model.Load(); m != nil && m.Name == model.Name {runners = append(runners, runner)}}@@ -1820,13 +1817,14 @@ func (s *Scheduler) loadedModels() []loadedModel {models := make([]loadedModel, 0, len(runners))for _, r := range runners {r.refMu.Lock()- if r.model == nil {+ m := r.model.Load()+ if m == nil {// Unloaded after the snapshot above was takenr.refMu.Unlock()continue}lm := loadedModel{- model: r.model,+ model: m,runner: r.runner,size: int64(r.totalSize),sizeVRAM: int64(r.vramSize),diff --git a/server/sched_test.go b/server/sched_test.goindex 15c5243f1..516490c38 100644--- a/server/sched_test.go+++ b/server/sched_test.go@@ -281,6 +281,11 @@ func newScenarioRequestWithContext(t *testing.T, ctx context.Context, modelNamereturn b}+func withModel(r *runnerRef, m *Model) *runnerRef {+ r.model.Store(m)+ return r+}+func getGpuFn(ctx context.Context, runners []ml.FilteredRunnerDiscovery) []ml.DeviceInfo {slog.Info("test getGpuFn called", "runners", runners)g := ml.DeviceInfo{DeviceID: ml.DeviceID{Library: "Metal"}}@@ -596,12 +601,12 @@ func TestSchedGetRunnerUsesDigestKeyWhenModelPathEmpty(t *testing.T) {loadedModel := &Model{Name: "safetensors-a", Digest: "sha-a"}loadedRunner := &runnerRef{- model: loadedModel,modelKey: schedulerModelKey(loadedModel),llama: &mockLlm{vramByGPU: map[ml.DeviceID]uint64{}},Options: &opts,numParallel: 1,}+ loadedRunner.model.Store(loadedModel)s.loadedMu.Lock()s.loaded[loadedRunner.modelKey] = loadedRunner@@ -633,12 +638,12 @@ func TestSchedGetRunnerUsesManifestDigestKeyWhenModelPathEmpty(t *testing.T) {loadedModel := &Model{Name: "list", Digest: "parent", ManifestDigest: "child-a"}loadedRunner := &runnerRef{- model: loadedModel,modelKey: schedulerModelKey(loadedModel),llama: &mockLlm{vramByGPU: map[ml.DeviceID]uint64{}},Options: &opts,numParallel: 1,}+ loadedRunner.model.Store(loadedModel)s.loadedMu.Lock()s.loaded[loadedRunner.modelKey] = loadedRunner@@ -662,12 +667,12 @@ func TestSchedGetRunnerReusesSameDigestWhenModelPathEmpty(t *testing.T) {loadedModel := &Model{Name: "safetensors-a", Digest: "sha-a"}loadedRunner := &runnerRef{- model: loadedModel,modelKey: schedulerModelKey(loadedModel),llama: &mockLlm{vramByGPU: map[ml.DeviceID]uint64{}},Options: &opts,numParallel: 1,}+ loadedRunner.model.Store(loadedModel)s.loadedMu.Lock()s.loaded[loadedRunner.modelKey] = loadedRunner@@ -917,14 +922,14 @@ func TestSchedNeedsReload(t *testing.T) {llm := &mockLlm{vramByGPU: map[ml.DeviceID]uint64{}}do := api.DefaultOptions()runner := &runnerRef{- model: &Model{- AdapterPaths: []string{"adapter1"},- ProjectorPaths: []string{"projector1"},- },Options: &do,llama: llm,numParallel: 1,}+ runner.model.Store(&Model{+ AdapterPaths: []string{"adapter1"},+ ProjectorPaths: []string{"projector1"},+ })req := &LlmRequest{model: &Model{AdapterPaths: []string{"adapter2"},@@ -934,10 +939,10 @@ func TestSchedNeedsReload(t *testing.T) {}resp := runner.needsReload(ctx, req)require.True(t, resp)- req.model.AdapterPaths = runner.model.AdapterPaths+ req.model.AdapterPaths = runner.model.Load().AdapterPathsresp = runner.needsReload(ctx, req)require.True(t, resp)- req.model.ProjectorPaths = runner.model.ProjectorPaths+ req.model.ProjectorPaths = runner.model.Load().ProjectorPathsrunner.loading = truereq.opts.NumBatch = 1234resp = runner.needsReload(ctx, req)@@ -995,12 +1000,12 @@ func TestSchedNeedsReloadIgnoresAutomaticNumCtxClamp(t *testing.T) {opts.NumCtx = 131072model := &Model{}runner := &runnerRef{- model: model,Options: &opts,llama: llm,numParallel: 1,numCtxAuto: true,}+ runner.model.Store(model)req := &LlmRequest{model: model,opts: api.DefaultOptions(),@@ -1023,13 +1028,13 @@ func TestSchedNeedsReloadUsesEffectiveAutomaticContextShift(t *testing.T) {opts.NumCtx = 128model := &Model{ModelPath: "model.gguf"}runner := &runnerRef{- model: model,Options: &opts,llama: llm,numParallel: 1,numCtxAuto: true,contextShift: true,}+ runner.model.Store(model)req := &LlmRequest{model: model,opts: api.DefaultOptions(),@@ -1052,13 +1057,13 @@ func TestSchedNeedsReloadUsesEffectiveExplicitContext(t *testing.T) {opts.NumCtx = 2048model := &Model{ModelPath: "model.gguf"}runner := &runnerRef{- model: model,Options: &opts,llama: llm,numParallel: 1,contextShift: true,trainContext: 2048,}+ runner.model.Store(model)req := &LlmRequest{model: model,opts: api.DefaultOptions(),@@ -1080,12 +1085,12 @@ func TestSchedNeedsReloadIgnoresAutomaticNumBatchDerivation(t *testing.T) {opts.NumBatch = 1024model := &Model{}runner := &runnerRef{- model: model,Options: &opts,llama: llm,numParallel: 1,numBatchAuto: true,}+ runner.model.Store(model)req := &LlmRequest{model: model,opts: api.DefaultOptions(),@@ -1109,12 +1114,12 @@ func TestSchedNeedsReloadIgnoresAutomaticUseMMapDefault(t *testing.T) {opts.UseMMap = &useMmapmodel := &Model{}runner := &runnerRef{- model: model,Options: &opts,llama: llm,numParallel: 1,useMMapAuto: true,}+ runner.model.Store(model)req := &LlmRequest{model: model,opts: api.DefaultOptions(),@@ -1241,11 +1246,11 @@ func TestSchedUnloadAllRunners(t *testing.T) {func TestSchedUnload(t *testing.T) {llm1 := &mockLlm{vramByGPU: map[ml.DeviceID]uint64{}}r1 := &runnerRef{llama: llm1, numParallel: 1}- r2 := &runnerRef{model: &Model{AdapterPaths: []string{"A"}}, numParallel: 1}+ r2 := withModel(&runnerRef{numParallel: 1}, &Model{AdapterPaths: []string{"A"}})r1.unload()require.True(t, llm1.closeCalled)r2.unload()- require.Nil(t, r2.model)+ require.Nil(t, r2.model.Load())}func TestSchedAlreadyCanceled(t *testing.T) {@@ -2081,18 +2086,18 @@ func TestSchedRuntimeOOMExpiresLoadedRunners(t *testing.T) {currentModel := &Model{ModelPath: "/tmp/current.gguf"}current := &runnerRef{- model: currentModel,modelKey: schedulerModelKey(currentModel),sessionDuration: time.Hour,llama: &mockLlm{modelPath: "/tmp/current.gguf"},}+ current.model.Store(currentModel)otherModel := &Model{ModelPath: "/tmp/other.gguf"}other := &runnerRef{- model: otherModel,modelKey: schedulerModelKey(otherModel),sessionDuration: time.Hour,llama: &mockLlm{modelPath: "/tmp/other.gguf"},}+ other.model.Store(otherModel)s.loadedMu.Lock()s.loaded[current.modelKey] = current@@ -2227,12 +2232,12 @@ func TestRunnerCanBeEvicted(t *testing.T) {s.getSystemInfoFn = getSystemInfoFnloadedRunner := &runnerRef{- model: &Model{Name: "test", ModelPath: "/fake/model"},modelPath: "/fake/model",llama: &mockLlm{vramSize: 21 * format.GigaByte, vramByGPU: map[ml.DeviceID]uint64{}},sessionDuration: 5 * time.Millisecond,refCount: 0, // idle}+ loadedRunner.model.Store(&Model{Name: "test", ModelPath: "/fake/model"})s.loadedMu.Lock()s.loaded["/fake/model"] = loadedRunner@@ -2256,22 +2261,22 @@ func TestSchedulerTracksMultipleLoadedRunners(t *testing.T) {s.getSystemInfoFn = getSystemInfoFnfirstRunner := &runnerRef{- model: &Model{Name: "first", ModelPath: "/fake/first/model"},modelPath: "/fake/first/model",llama: &mockLlm{vramSize: 8 * format.GigaByte, vramByGPU: map[ml.DeviceID]uint64{{Library: "Metal"}: 8 * format.GigaByte}},sessionDuration: 10 * time.Millisecond,numParallel: 1,refCount: 0,}+ firstRunner.model.Store(&Model{Name: "first", ModelPath: "/fake/first/model"})secondRunner := &runnerRef{- model: &Model{Name: "second", ModelPath: "/fake/second/model"},modelPath: "/fake/second/model",llama: &mockLlm{vramSize: 4 * format.GigaByte, vramByGPU: map[ml.DeviceID]uint64{{Library: "Metal"}: 4 * format.GigaByte}},sessionDuration: 10 * time.Millisecond,numParallel: 1,refCount: 0,}+ secondRunner.model.Store(&Model{Name: "second", ModelPath: "/fake/second/model"})s.loadedMu.Lock()s.loaded["/fake/first/model"] = firstRunnerdiff --git a/server/systemone_test.go b/server/systemone_test.goindex 26bba11b9..7948e460a 100644--- a/server/systemone_test.go+++ b/server/systemone_test.go@@ -315,7 +315,7 @@ func TestSystemOneHandler(t *testing.T) {s := newServerWithMockRunner(t, &runner.mockRunner)s.sched.loadFn = func(req *LlmRequest, _ ml.SystemInfo, _ []ml.DeviceInfo, _ bool) bool {runner.contextLength = req.opts.NumCtx- ref.model = req.model+ ref.model.Store(req.model)ref.modelKey = schedulerModelKey(req.model)s.sched.loadedMu.Lock()s.sched.loaded[ref.modelKey] = ref@@ -333,7 +333,7 @@ func TestSystemOneHandler(t *testing.T) {if w.Code != tt.status || runner.calls != tt.calls {t.Fatalf("status=%d calls=%d body=%s", w.Code, runner.calls, w.Body)}- if tt.calls == 0 && tt.err == nil && ref.model != nil {+ if tt.calls == 0 && tt.err == nil && ref.model.Load() != nil {t.Fatal("loaded a runner for a rejected request")}if strings.HasPrefix(tt.name, "score limits/") && tt.status == http.StatusBadRequest &&@@ -390,7 +390,7 @@ func TestSystemOneHandler(t *testing.T) {t.Fatal(err)}outputTokens := 2- if len(runner.request.Fields) > 0 || runner.native || ref.model.Config.Renderer == "kev" || ref.model.Config.Renderer == "pplx" {+ if len(runner.request.Fields) > 0 || runner.native || ref.model.Load().Config.Renderer == "kev" || ref.model.Load().Config.Renderer == "pplx" {outputTokens = 0}if response.Answers["refund"].Noul < 0.88 || response.Usage.InputTokens != 123 || response.Usage.OutputTokens != outputTokens {@@ -402,17 +402,17 @@ func TestSystemOneHandler(t *testing.T) {}return}- if ref.model.Config.Renderer == "strands" && (len(runner.request.PointerRows) != 1 || len(runner.request.Rows) != 0 || !strings.HasSuffix(runner.request.PointerRows[0].Prompt, "<answer>")) {+ if ref.model.Load().Config.Renderer == "strands" && (len(runner.request.PointerRows) != 1 || len(runner.request.Rows) != 0 || !strings.HasSuffix(runner.request.PointerRows[0].Prompt, "<answer>")) {t.Fatalf("Strands did not receive pointer inputs: %+v", runner.request)}- if ref.model.Config.Renderer == "pplx" && (runner.request.System != "Model-specific scoring instructions." || len(runner.request.Rows) != 1 || runner.request.Rows[0].Question == nil) {+ if ref.model.Load().Config.Renderer == "pplx" && (runner.request.System != "Model-specific scoring instructions." || len(runner.request.Rows) != 1 || runner.request.Rows[0].Question == nil) {t.Fatalf("Perplexity scorer lost its system prompt or native question: %+v", runner.request)}var prompt stringif len(runner.request.Rows) > 0 {prompt = runner.request.Rows[0].Prompt}- if ref.model.Config.Renderer == "tev1" && (!strings.Contains(prompt, `"state": "x", "question": "q", "options":`) || strings.Contains(prompt, "Requested field:")) {+ if ref.model.Load().Config.Renderer == "tev1" && (!strings.Contains(prompt, `"state": "x", "question": "q", "options":`) || strings.Contains(prompt, "Requested field:")) {t.Fatalf("Tev1 did not receive its per-question prompt: %q", prompt)}if len(runner.request.Fields) > 0 {@@ -423,21 +423,21 @@ func TestSystemOneHandler(t *testing.T) {if len(runner.request.Rows) != 0 {t.Fatal("pointer head must bypass chat templates")}- } else if ref.model.HasGoTemplate {+ } else if ref.model.Load().HasGoTemplate {if !strings.HasPrefix(prompt, "custom:system:Model-specific scoring instructions.\nuser:") || !strings.HasSuffix(prompt, "answer:") {t.Fatalf("scorer did not receive the Modelfile template output: %q", prompt)}- } else if ref.model.Config.Renderer == "pplx" {+ } else if ref.model.Load().Config.Renderer == "pplx" {if prompt != "" {t.Fatalf("Perplexity scorer received a generic rendered prompt: %q", prompt)}- } else if ref.model.Config.Renderer == "kev" {+ } else if ref.model.Load().Config.Renderer == "kev" {if prompt != "" || len(runner.request.State) != 70<<10 || runner.request.Rows[0].Question == nil {t.Fatalf("Kev scorer received a rendered prompt or lost the state/question")}} else {wantPrefix := "<|im_start|>user\n"- if ref.model.System != "" {+ if ref.model.Load().System != "" {wantPrefix = "<|im_start|>system\nModel-specific scoring instructions.<|im_end|>\n<|im_start|>user\n"}if !strings.HasPrefix(prompt, wantPrefix) || !strings.HasSuffix(prompt, "<think>\n\n</think>\n\n") {