Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ and the project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.

### Fixed

- An audio card's `supports` now follow `MODEL_SUPPORTS` on every boot. The
card sits on the shared cache and outlives the application, so a reinstall
or a chart that added a capability kept the first install's supports:
Router routed only those while the engine, which mounts its routes from
the env, served more, and the card could not be corrected at runtime
because audio supports are refused there. This is a third exception to
disk-wins, for audio engines only; other cards keep theirs.
- The model card's `extensions.capacity` now follows an engine whose pod an
upgrade replaced. The capacity reporter re-read the engine only on a
readiness dip or a relaunch this process asked for, and a replaced pod
Expand Down
19 changes: 19 additions & 0 deletions internal/config/config_load_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"maps"
"os"
"strings"

Expand Down Expand Up @@ -363,6 +364,24 @@ func reasoningEffortRuleFromEnv(g Getenv) (*ParameterRule, error) {
return &rule, nil
}

// overlayAudioSupportsFromEnv makes MODEL_SUPPORTS authoritative for an
// audio engine's supports on an existing card. Returns true when spec was
// mutated.
//
// An audio card's supports cannot be edited at runtime (runtimecfg refuses
// it): the engine mounts its routes from MODEL_SUPPORTS, so the card has to
// say the same. The card outlives the application on the shared cache, so
// without this a reinstall or a chart that adds a capability keeps the old
// card, and Router routes only what the first install declared while the
// engine serves more. An unset MODEL_SUPPORTS leaves the card alone.
func overlayAudioSupportsFromEnv(cfg *Config, spec *ModelSpec) bool {
if cfg.Engine.Kind != EngineAudio || len(cfg.Spec.Supports) == 0 || maps.Equal(spec.Supports, cfg.Spec.Supports) {
return false
}
spec.Supports = maps.Clone(cfg.Spec.Supports)
return true
}

// overlayReasoningEffortRuleFromEnv makes the chart authoritative for the
// reasoning_effort rule on an existing card, leaving every other rule
// alone. Returns true when spec was mutated.
Expand Down
3 changes: 3 additions & 0 deletions internal/config/modelspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ func ReconcileModelSpecFile(cfg *Config) error {
if overlayReasoningEffortRuleFromEnv(&spec) {
rewrote = true
}
if overlayAudioSupportsFromEnv(cfg, &spec) {
rewrote = true
}
// One-shot backfill only when the on-disk JSON lacks the
// engine_args key entirely (legacy files). An explicit empty
// string (or null) means the operator cleared the card — do not
Expand Down
62 changes: 62 additions & 0 deletions internal/config/modelspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"log/slog"
"maps"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -907,3 +908,64 @@ func TestReconcileModelSpecFile_NoWarnWhenCardMatchesChartSeed(t *testing.T) {
t.Errorf("identical args must not warn, got: %s", logs)
}
}

// An audio card on the shared cache outlives the application, so a reinstall
// that declares more capabilities met the first install's card. Its supports
// follow MODEL_SUPPORTS, which is what the engine mounts its routes from;
// the rest of the card is still the disk's.
func TestReconcileModelSpecFile_AudioSupportsFollowTheEnv(t *testing.T) {
t.Parallel()
path := writeSpec(t, `{"name":"disk","mode":"audio","supports":{"supports_stt":true},"engine_args":""}`)
want := parseSupportsCSV("supports_stt,supports_diar")
cfg := &Config{
Runtime: Runtime{ModelSpecPath: path},
Engine: Engine{Kind: EngineAudio},
Spec: ModelSpec{Name: "seed", Mode: "audio", Supports: maps.Clone(want)},
}
if err := ReconcileModelSpecFile(cfg); err != nil {
t.Fatalf("reconcile: %v", err)
}
if !maps.Equal(cfg.Spec.Supports, want) {
t.Errorf("supports = %v, want %v", cfg.Spec.Supports, want)
}
got, err := LoadModelSpecFile(path)
if err != nil {
t.Fatalf("reload: %v", err)
}
if !maps.Equal(got.Supports, want) || got.Name != "disk" {
t.Errorf("disk card = %+v, want the env's supports written through and the disk's name kept", got)
}
}

// Only audio cards: other engines' supports are edited through Router, and
// disk wins for them. An audio deployment without MODEL_SUPPORTS keeps its
// card.
func TestReconcileModelSpecFile_AudioSupportsOverlayIsAudioOnly(t *testing.T) {
t.Parallel()
for name, cfg := range map[string]*Config{
"chat engine": {
Engine: Engine{Kind: EngineLlamaCpp},
Spec: ModelSpec{Mode: "chat", Supports: parseSupportsCSV("supports_vision")},
},
"audio without MODEL_SUPPORTS": {
Engine: Engine{Kind: EngineAudio},
Spec: ModelSpec{Mode: "audio"},
},
} {
disk := `{"name":"disk","mode":"chat","supports":{"supports_reasoning":true}}`
if cfg.Engine.Kind == EngineAudio {
disk = `{"name":"disk","mode":"audio","supports":{"supports_stt":true},"engine_args":""}`
}
cfg.Runtime.ModelSpecPath = writeSpec(t, disk)
var before ModelSpec
if err := json.Unmarshal([]byte(disk), &before); err != nil {
t.Fatal(err)
}
if err := ReconcileModelSpecFile(cfg); err != nil {
t.Fatalf("%s: reconcile: %v", name, err)
}
if !maps.Equal(cfg.Spec.Supports, before.Supports) {
t.Errorf("%s: supports = %v, want the disk's %v", name, cfg.Spec.Supports, before.Supports)
}
}
}
Loading