flux and sf3d on one card handed it to each other, each starting ComfyUI and loading its weights from nothing (BACKLOG H3, placement side). An environment of two or more models now gets a hidden catalog entry, comfyui-env-<name>: on its first member's profiles with the most memory any member needs, on demand for the longest idle timeout, carrying every member's weights, repositories and the environment's custom nodes. The members get no replicas of their own; asking for one wants the entry. The agent fetches each member's weights; the gate links all of them, refusing two weights files of one name, links each member's Hugging Face repository, and answers /v1/models for every member. The control plane offers the replica under the members' names with each one's workflow and checkpoint, which the router sends by the model asked for. A member's sibling never evicts the replica serving it, and the members' load counts as the entry's. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
58 lines
1.9 KiB
Go
58 lines
1.9 KiB
Go
package reconciler
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/catalog"
|
|
)
|
|
|
|
func sharedCatalog(t *testing.T) *catalog.Catalog {
|
|
t.Helper()
|
|
mk := func(name, out string) catalog.Model {
|
|
return catalog.Model{Name: name, Source: "/w/" + name + ".safetensors",
|
|
ComfyUI: &catalog.ComfyUI{Environment: "art", Workflow: "flux-schnell", Output: out},
|
|
Scaling: catalog.Scaling{Max: 1, IdleTimeout: time.Hour},
|
|
Profiles: []catalog.Profile{{Name: "p", Engine: catalog.EngineComfyUI, GPUClass: "h100-80g", TP: 1}}}
|
|
}
|
|
cat, err := catalog.New([]catalog.Model{mk("flux", catalog.OutputPictures), mk("sf3d", catalog.OutputMeshes)})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return cat
|
|
}
|
|
|
|
func TestAMemberAskedForStartsItsEnvironmentsOneReplica(t *testing.T) {
|
|
// A picture model and a 3D model on one card took turns, each from
|
|
// nothing: in one environment, asking for either starts one replica
|
|
// that serves both, and neither gets one of its own.
|
|
h := newHarness(t, testModel(1), gpuNode("1", 1))
|
|
h.r.cat.Store(sharedCatalog(t))
|
|
if !h.r.Want("sf3d") {
|
|
t.Fatal("a member was not wanted")
|
|
}
|
|
h.r.Reconcile(t.Context())
|
|
h.markReady()
|
|
h.r.Want("flux")
|
|
h.r.Reconcile(t.Context())
|
|
var models []string
|
|
for _, rep := range h.r.Replicas() {
|
|
if rep.State.Counts() {
|
|
models = append(models, rep.Model)
|
|
}
|
|
}
|
|
if len(models) != 1 || models[0] != "comfyui-env-art" {
|
|
t.Fatalf("replicas %v", models)
|
|
}
|
|
// The member's sibling never evicts the replica serving it.
|
|
reps := h.r.Replicas()
|
|
h.r.RecordUsage(map[string]time.Time{reps[0].ID: h.clock.now()})
|
|
h.advance(DefaultConfig().MinLifetime + DefaultConfig().EvictionGrace + time.Minute)
|
|
if got := h.r.evictable("flux"); len(got) != 0 {
|
|
t.Errorf("a member was offered its own environment's replica: %+v", got)
|
|
}
|
|
if _, _, ok := h.r.WaitFor("flux"); ok {
|
|
t.Error("a member served by a replica that is up was said to be waiting")
|
|
}
|
|
}
|