Serve a mirrored model from the list, instead of writing YAML for it
Fetching a model put it on the mirror and left the operator to hand-write a catalogue entry and run `ctl model add` on the control plane — for a source the page was already displaying, with an engine decided by the file extension it had just shown them. A present row now offers to serve it. The form opens on that row with the name, the mirror's own URL and the engine filled in, and asks for the two things nobody can infer: the context pool and how many replicas. What it refuses is the point. A version of several files is refused with the reason. A catalogue entry names one source, so an entry for a sharded model is an entry for one shard, which loads as a broken model rather than failing to load. Nothing said so before — the mirror happily holds a four-shard model that no catalogue entry can describe. Safetensors on a fleet with no GPU is warned about before anything is added. This is the failure we hit today: fifteen gigabytes of shards arrived, and only then did looking at a node show no card, no vLLM and no SGLang. The control plane is not told which engines a node has installed, so the check is on cards, which it does know — a warning rather than a refusal, because a card can be added tomorrow. A name already declared in configuration is refused here too, matching what the model service would say anyway, but before the form is filled in rather than after. Without a store there is no serve action at all: a model added at runtime would not survive a restart, and offering it then refusing is worse than not offering. The mirror page's dependencies became a struct. Three are optional interfaces and two are the same shape, which at a call site is a swap nobody notices until a page shows the wrong thing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a588646b7c
commit
e034862b79
9 files changed
+539
-4
No files matched your search
@@ -60,6 +60,11 @@ type mirrorRow struct {
|
||||
// somebody will copy, so it is rendered rather than left to be assembled.
|
||||
URL string
|
||||
Percent int
|
||||
// Serve is the offer to put this version into service, open on the row the
|
||||
// operator clicked. Nil on a row that is still arriving: a catalog entry
|
||||
// pointing at a partial file is the thing versioned paths exist to prevent.
|
||||
Serve *serveForm
|
||||
|
||||
// HasPercent is false when the upstream never sent a length. The bar is
|
||||
// then not drawn at all: a progress bar that has to invent its own total is
|
||||
// worse than a byte count that only goes up.
|
||||
@@ -80,6 +85,10 @@ type adminMirrorData struct {
|
||||
// a mirror waiting to be filled, the other is a machine to go and look at.
|
||||
Unreachable bool
|
||||
|
||||
// HasCatalog is false where the catalogue cannot be changed at runtime, and
|
||||
// the serve action is then not offered rather than offered and refused.
|
||||
HasCatalog bool
|
||||
|
||||
// The explorer.
|
||||
HasRegistry bool
|
||||
Query string
|
||||
@@ -107,9 +116,29 @@ type adminMirrorData struct {
|
||||
// need a shell for, while anything that would let a stolen session reach
|
||||
// further — pointing the control plane at a different mirror, say — stays in
|
||||
// configuration where changing it means access to the host.
|
||||
func (p *AccountPages) RegisterAdminMirror(mux *http.ServeMux, m MirrorAdmin, reg Registry) {
|
||||
// MirrorDeps is what the mirror page can reach.
|
||||
//
|
||||
// A struct rather than five parameters: three of them are optional interfaces
|
||||
// and two are the same shape, which at a call site is a swap nobody notices
|
||||
// until a page shows the wrong thing.
|
||||
type MirrorDeps struct {
|
||||
Mirror MirrorAdmin
|
||||
// Registry browses a model registry. Nil turns the explorer off.
|
||||
Registry Registry
|
||||
// Catalog puts a mirrored model into service. Nil leaves the serve action
|
||||
// off, which is right where the catalogue cannot be changed at runtime.
|
||||
Catalog CatalogAdmin
|
||||
// Fleet is the cluster, for saying whether anything could run a model
|
||||
// before somebody spends an hour downloading it.
|
||||
Fleet Source
|
||||
}
|
||||
|
||||
func (p *AccountPages) RegisterAdminMirror(mux *http.ServeMux, d MirrorDeps) {
|
||||
m := d.Mirror
|
||||
p.hasMirror = true
|
||||
p.registry = reg
|
||||
p.registry = d.Registry
|
||||
p.catalog = d.Catalog
|
||||
p.fleet = d.Fleet
|
||||
|
||||
mux.HandleFunc("GET /admin/mirror", p.adminOnly(
|
||||
func(w http.ResponseWriter, r *http.Request, _ store.User) {
|
||||
@@ -153,6 +182,24 @@ func (p *AccountPages) RegisterAdminMirror(mux *http.ServeMux, m MirrorAdmin, re
|
||||
model, version, plural(started, "file", "files")), nil
|
||||
}))
|
||||
|
||||
if d.Catalog != nil {
|
||||
mux.HandleFunc("POST /admin/mirror/serve", p.mirrorAction(m,
|
||||
func(ctx context.Context, admin store.User, r *http.Request) (string, error) {
|
||||
model, err := buildModel(r.FormValue)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := d.Catalog.Add(ctx, model, admin.Email); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Placed on the next pass, not now: saying it is serving would
|
||||
// be wrong for however long the weights take to reach a node.
|
||||
return fmt.Sprintf(
|
||||
"%s added to the catalog, %s; it is placed on the next pass",
|
||||
model.Name, plural(model.Scaling.Min, "replica", "replicas")), nil
|
||||
}))
|
||||
}
|
||||
|
||||
mux.HandleFunc("POST /admin/mirror/{model}/{version}/remove", p.mirrorAction(m,
|
||||
func(ctx context.Context, _ store.User, r *http.Request) (string, error) {
|
||||
model, ver := r.PathValue("model"), r.PathValue("version")
|
||||
@@ -204,6 +251,7 @@ func (p *AccountPages) renderMirror(w http.ResponseWriter, r *http.Request,
|
||||
Now: time.Now().UTC().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
d.HasCatalog = p.catalog != nil
|
||||
p.explore(r, &d)
|
||||
|
||||
got, err := m.List(r.Context())
|
||||
@@ -238,6 +286,27 @@ func (p *AccountPages) renderMirror(w http.ResponseWriter, r *http.Request,
|
||||
d.Rows = append(d.Rows, row)
|
||||
}
|
||||
|
||||
// The one row whose serve form is open, and only when the catalog can be
|
||||
// changed at all.
|
||||
if p.catalog != nil {
|
||||
if want := r.URL.Query().Get("serve"); want != "" {
|
||||
byVersion := map[string][]mirror.Status{}
|
||||
for _, st := range got.Models {
|
||||
byVersion[st.Model+"/"+st.Version] = append(byVersion[st.Model+"/"+st.Version], st)
|
||||
}
|
||||
for i := range d.Rows {
|
||||
key := d.Rows[i].Model + ":" + d.Rows[i].Version
|
||||
if key != want || d.Rows[i].State != mirror.Present {
|
||||
continue
|
||||
}
|
||||
form := planServe(d.Rows[i].Status,
|
||||
byVersion[d.Rows[i].Model+"/"+d.Rows[i].Version], got.Base, p.fleet, p.catalog)
|
||||
d.Rows[i].Serve = &form
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Downloads first, then failures, then what is simply here. The two states
|
||||
// somebody opened this page for are at the top; the rest is a list they
|
||||
// scroll. Within a state the order is fixed so rows do not shuffle between
|
||||
|
||||
Reference in new issue
Block a user