Canary of a model's newer weights: ctl model canary, promote and canaries, rolled back by itself when it serves worse

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 20:31:26 +02:00
1 parent 0a4076928a
commit a1dfd4df1d
13 files changed
+750 -18

No files matched your search

+40 -13
View File
@@ -33,6 +33,11 @@ type Models interface {
Declared(name string) bool
SetSource(ctx context.Context, name, source string, origin *catalog.Origin, by string) (catalog.Model, error)
SetOrigin(ctx context.Context, name string, origin *catalog.Origin) error
// For a canary: the candidate added beside the model and taken out
// again, and the share of requests it is given.
Add(ctx context.Context, m catalog.Model, by string) error
Remove(ctx context.Context, name string) error
SetCanary(ctx context.Context, name string, c *catalog.Canary, by string) (catalog.Model, error)
}
// UpdateInfo is what the registry has for a model against what it runs.
@@ -451,32 +456,43 @@ func (s *Server) StartUpdate(name, by string) (Job, error) {
return s.snapshot(j), nil
}
func (s *Server) runUpdate(j *Job) {
ctx := context.Background()
name := j.Model
// prepared is a model's new weights, fetched and checked: what an update and
// a canary both start from.
type prepared struct {
m catalog.Model
o *catalog.Origin
repo hf.Repo
set hf.FileSet
source string
}
// prepare reads where a model came from, fetches its repository's newer
// files into the mirror beside the ones in use, and checks the nodes can
// load them. It fails the job and says false when any of that cannot be.
func (s *Server) prepare(ctx context.Context, j *Job, name string) (prepared, bool) {
// 1. The registry: which files, at which commit.
s.step(j, "registry", Running, "reading where "+name+" came from")
m, err := s.current(name)
if err != nil {
s.fail(j, "registry", err)
return
return prepared{}, false
}
list, err := s.deps.Mirror.List(ctx)
if err != nil {
s.fail(j, "registry", fmt.Errorf("the mirror: %w", err))
return
return prepared{}, false
}
o := s.originOf(ctx, m, list)
p, onMirror := placeOf(m.Source, list)
if o == nil || !onMirror {
s.fail(j, "registry", fmt.Errorf("%s did not come from the registry through the mirror", name))
return
return prepared{}, false
}
repo, err := s.deps.Registry.Repo(ctx, o.Repo)
if err != nil {
s.fail(j, "registry", err)
return
return prepared{}, false
}
s.mu.Lock()
j.Request.Repo = repo.ID
@@ -485,18 +501,18 @@ func (s *Server) runUpdate(j *Job) {
switch {
case sameRevision(repo.Revision, o.Revision):
s.fail(j, "registry", fmt.Errorf("%s already runs %s's latest commit, %s", name, repo.ID, catalog.ShortRevision(repo.Revision)))
return
return prepared{}, false
case len(u.Missing) > 0:
s.fail(j, "registry", fmt.Errorf("%s at %s no longer has %s; choose one of its files and serve it under a new name",
repo.ID, repo.ShortRevision(), strings.Join(u.Missing, ", ")))
return
return prepared{}, false
case len(u.Changed) == 0:
s.fail(j, "registry", fmt.Errorf("%s has a newer commit, %s, but the files %s runs are the same in it",
repo.ID, repo.ShortRevision(), name))
return
return prepared{}, false
case repo.Gated.Is():
s.fail(j, "registry", fmt.Errorf("%s is gated: it needs an account's approval the mirror does not have", repo.ID))
return
return prepared{}, false
}
set := hf.FileSet{}
for _, f := range o.Files {
@@ -512,7 +528,7 @@ func (s *Server) runUpdate(j *Job) {
source, err := s.mirror(ctx, j, repo, set, p.model)
if err != nil {
s.fail(j, "mirror", err)
return
return prepared{}, false
}
// 3. Whether the nodes load it, and whether it still fits what is
@@ -523,7 +539,7 @@ func (s *Server) runUpdate(j *Job) {
v := gguf.Check(ctx, u, s.deps.LlamaVersion)
if !v.Servable {
s.fail(j, "check", fmt.Errorf("llama.cpp %s on the nodes cannot run the new weights: %s", s.deps.LlamaVersion, v.Reason))
return
return prepared{}, false
}
detail = orUnknown(v.Header.Architecture)
if len(m.Profiles) > 0 {
@@ -540,6 +556,17 @@ func (s *Server) runUpdate(j *Job) {
}
}
s.step(j, "check", Done, detail)
return prepared{m: m, o: o, repo: repo, set: set, source: source}, true
}
func (s *Server) runUpdate(j *Job) {
ctx := context.Background()
name := j.Model
p, ok := s.prepare(ctx, j, name)
if !ok {
return
}
m, o, repo, set, source := p.m, p.o, p.repo, p.set, p.source
// 4. The catalog: the new source, and the old one kept to go back to.
s.step(j, "catalog", Running, "moving "+name+" to "+repo.ShortRevision())