tierseed

package
v0.207.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tierseed resolves a hardware tier's config_seed into the harness config fragment an install should start from.

The seeds existed only inside install.ps1, which meant a tier's media binding was both Windows-shaped (`sd-cli.exe` baked into the table) and PowerShell-only. A tier is a HARDWARE class: the same tier on Linux must produce the same capabilities, so the resolution lives here — one implementation, cross-compiled, testable — and the wrappers become consumers.

It also VALIDATES, because a seed is config that ships to every machine of that class and a typo in it is a capability that silently never works:

  • every key must be a real Config field (a misspelled seed key would be dropped by the loader with only a warning, on every install of that tier);
  • no literal ".exe" — binaries carry the __EXE__ token so one seed renders on both platforms;
  • vae_mode is rejected as "cpu" on a CUDA backend, where it was MEASURED at 7.8x slower (58.2s vs 7.5s) — correct on an AMD/UMA part, a trap everywhere else.

Index

Constants

View Source
const (
	TokenHome = "__OFFLOAD_HOME__"
	TokenExe  = "__EXE__"
)

Tokens a seed value may carry. They exist so ONE table row renders correctly on every machine and OS: the install root differs per machine (see the `home` key), and the executable suffix differs per platform.

Variables

This section is empty.

Functions

func FillPairAgent

func FillPairAgent(layers []config.LayerSpec, seat *vllmseat.Spec, active bool) []config.LayerSpec

FillPairAgent resolves the tier table's BARE agent seat — the one a composite tier leaves as `{"role": "agent"}` so the seat's numbers live in exactly one place (vllm_seat) — into a full seat: the vLLM seat's first alias, window and max_num_seqs when the box actually runs it, the tier's declared fallback when it does not. Exported because the SEED is not the only consumer: `install render` checks the rendered config against the same resolved layers (servingtmpl.CheckComposite), and a check run against the bare declaration would report the agent seat as placeable on nothing. The input is never mutated.

func Load

func Load(root string) (map[string]Profile, error)

Load reads the profile table from a repo root.

func Parse

func Parse(raw []byte) (map[string]Profile, error)

Parse reads the profile table from bytes — the install case, where the table is embedded in the binary because the machine has no checkout.

func RAMLowUp

func RAMLowUp(ramTier string) bool

RAMLowUp reports whether a detected ram_tier is the 32 GB class or above (low, mid, high: hwdetect.RAMTier >= 28 GB): the boxes config_seed_ram_low_up applies to. It is exported because the serving render gates the RAM-spill agent seat on the SAME predicate (install_render.go spillSeatIncluded) — the seed that binds agent_model to the seat and the render that serves it must agree on which boxes get it, and sharing the predicate is what makes that structural instead of a convention. Anything else, including "" (the caller does not know) and an unrecognised name, is false: the overlay is opt-in. Case and surrounding whitespace do not matter ("LOW", " low "): `install render` normalises its --ram-tier before it asks, so this predicate must too, or `install seed` handed the same flag would leave agent_model on the 4B while the render serves the spill seat.

func Resolve

func Resolve(p Profile, id string, opt Options) (map[string]any, error)

Resolve renders one tier's seed for a target machine: overlay applied, tokens expanded, vae_mode translated, and the whole thing validated. The result is ready to merge into a config.json.

func ResolveAccelerators

func ResolveAccelerators(accs map[string]Accelerator, ids []string, opt Options) (map[string]any, error)

ResolveAccelerators merges the seeds of the listed accelerator ids, validates every key against config.Config, and expands __HAILO_HOME__ / __CORAL_HOME__ / __RKNPU_HOME__ (plus the usual __OFFLOAD_HOME__/__EXE__). An id with no entry is an authoring error — an installer that detected a device the table does not describe must say so.

This function is the single authority on the rule; install.ps1 carries a PowerShell parity copy for the no-Go-binary path — change it here first.

func ResolveLayers

func ResolveLayers(layers []config.LayerSpec, s VLLMSeatSet) []config.LayerSpec

ResolveLayers turns a tier's DECLARED layers into what a box actually serves. It is exported because the seed is not its only consumer: `install render` checks the rendered serving config against these same layers.

  • A bare agent seat ({"role": "agent"}) derives from the lane seat exactly as FillPairAgent does: the vLLM seat when the box runs it, else its fallback.
  • A seat whose model NAMES a declared vLLM seat (by id or alias) is served only while that seat runs: otherwise it is dropped, and a layer left with no seat is dropped with it. The seeded config never advertises a layer the box cannot serve.
  • `single` is the planner-default layer (placement row 5b: a box that declares no pair routes every agent contract to it). A layer set that declared `single` and lost it would make the node ineligible for every contract it ran the day before, so the whole set resolves to none — the box is then a plain, non-composite box.

The input is never mutated: one Profile resolves for many boxes.

Types

type Accelerator

type Accelerator struct {
	Kind       string         `json:"kind"`
	Owns       []string       `json:"owns"`
	ConfigSeed map[string]any `json:"config_seed"`
	Notes      string         `json:"notes"`
}

Accelerator is one profiles.json `accelerators` entry: an additive device beside the GPU tier (ADR 0024). Its seed merges AFTER the tier's own seed.

type Doc

type Doc struct {
	Profiles     map[string]Profile     `json:"profiles"`
	Accelerators map[string]Accelerator `json:"accelerators"`
}

Doc is the whole profiles.json document this package reads: the GPU tier table plus the additive accelerators table (ADR 0024).

func LoadDoc

func LoadDoc(root string) (Doc, error)

LoadDoc reads the whole document (profiles + accelerators) from a repo root.

func ParseDoc

func ParseDoc(raw []byte) (Doc, error)

ParseDoc reads the whole document from bytes. Every profile's `layers` block is held to config.ValidateLayerKeys BEFORE Validate sees the decoded value: json.Unmarshal drops a key it cannot match without a word, so `host_ram_gb` on the triple layer's seat decoded as host_ram_gib 0, Validate/ValidateLayers saw a well-formed seat, and the installer seeded a host_ram guard that reads `free ≥ 0` — fail-open from one dropped character. The strict pass needs the raw bytes, which is why it lives here and not in Validate; Parse, Load and LoadDoc all route through this function, so the embedded copy the installer ships cannot carry a misspelt layer key either.

func (Doc) Validate

func (d Doc) Validate() error

Validate refuses the composite shapes the table cannot seed truthfully, at PARSE time so the embedded copy the installer ships cannot carry them: a `composes` id or a layer tier that is not in the table would seed a `tiers` list naming a tier no install can resolve, and health would advertise it to the fleet; composes without layers would seed nothing, silently; a tier composing itself or another composite has no defined layer set. The seeded layers are then run through config's own validator in BOTH bindings (vLLM seat active and fallback), because either is what an install writes. It runs from ParseDoc, which Parse and Load both route through, so every reader of the table gets the same refusal.

type Options

type Options struct {
	// Home is the install root substituted for __OFFLOAD_HOME__. Forward slashes are
	// used verbatim: the harness accepts them on Windows and they survive JSON.
	Home string
	// GOOS selects the executable suffix. "" = the running platform.
	GOOS string
	// RAMTier selects the RAM-gated overlays: config_seed_ram_low_up on "low"/"mid"/"high"
	// (RAMLowUp) and config_seed_ram_mid_high on "mid"/"high". "" or "min" applies neither.
	RAMTier string
	// HailoHome is the Hailo repo checkout __HAILO_HOME__ expands to.
	HailoHome string
	// CoralHome is the Coral sidecar home __CORAL_HOME__ expands to (its venv,
	// models/ and the accelerators/coral/ scripts live under it; Coral D3).
	CoralHome string
	// RknpuHome is the RKNPU sidecar home __RKNPU_HOME__ expands to (its venv, models/
	// and the accelerators/rknpu/ scripts live under it).
	RknpuHome string
	// VLLMSeatActive says whether THIS box renders the tier's vLLM agent seat. The
	// caller decides it with vllmseat.Spec.Detect — the engine is a hand-built venv
	// the installer does not create, so a box without it binds the fallback seat. The
	// binding and the rendered llama-swap entry therefore agree by construction: both
	// are driven by the same detection.
	VLLMSeatActive bool
	// ExtraVLLMSeatsActive names, by seat id, which of the tier's EXTRA vLLM seats
	// (Profile.ExtraVLLMSeats) this box can run. The caller decides each one with
	// vllmseat.Spec.DetectExtra: the seats share the venv, and each needs its own weights
	// and the wrapper scripts its entry runs (the operator installs those). An extra seat
	// that is absent here is neither rostered nor bound, and the layer it backs is left out
	// of the seeded layers — the config never advertises a seat the box cannot serve.
	ExtraVLLMSeatsActive map[string]bool
}

Options describe the machine the seed is being resolved FOR — never the machine doing the resolving, so a Windows box can render a Linux node's config.

type Profile

type Profile struct {
	Backend    string         `json:"backend"`
	ConfigSeed map[string]any `json:"config_seed"`
	// ConfigSeedLowUp is the RAM-gated overlay for the 32 GB class and up: applied when the
	// detected ram_tier is low, mid or high (28 GB and above), never on min. It exists for a
	// binding whose seat needs host RAM a `min` box does not have but a `low` box does (the
	// ampere-6 Qwen3.6-35B-A3B spill seat, ~11.6 GB resident); the mid/high overlay below
	// cannot say that, because the 32 GB reference box classifies as `low`. When both apply,
	// the mid/high value wins key by key.
	ConfigSeedLowUp   map[string]any `json:"config_seed_ram_low_up"`
	ConfigSeedMidHigh map[string]any `json:"config_seed_ram_mid_high"`
	// ResidentTier is the tier's preferred hot model. It SEEDS the agent planner
	// seat (agent_model) when it differs from the workhorse — see Resolve.
	ResidentTier string `json:"resident_tier"`
	// AgentCtxTokens is the tier's agent context window. Resolve seeds it as
	// agent_ctx_tokens unless config_seed or a vLLM seat binding already set it. It used
	// to reach a config only through install.ps1, which wrote the tier field directly;
	// install.sh never did, so every fresh LINUX node (<node-f>, <node-c>) got the code
	// default instead of the window its tier was measured at. Seeding it here gives both
	// installers the same value from one place.
	AgentCtxTokens int `json:"agent_ctx_tokens"`
	// MediaSeats are the tier's alias-backed media capabilities. They are the SOLE
	// writer of the config keys they bind — see mediaseat.Bindings.
	MediaSeats []mediaseat.Seat `json:"media_seats"`
	// VLLMSeat is the tier's persistent vLLM agent seat (ADR 0035). When the box can
	// actually run it (Options.VLLMSeatActive), it is the SOLE writer of agent_model
	// and agent_ctx_tokens; otherwise its declared fallback is.
	VLLMSeat *vllmseat.Spec `json:"vllm_seat,omitempty"`
	// ExtraVLLMSeats are the tier's further vLLM seats: served on demand beside VLLMSeat
	// on the same card, and never the agent lane — they never bind agent_model, so each
	// is validated as a non-lane seat (vllmseat.Spec.ValidateExtra) and carries no
	// fallback. They exist because a card can serve more than one heavy model in turn
	// (ampere-16: the 27B lane seat and the 35B fast digest seat), and the second seat
	// and the layer it backs lived only in a reference box's hand-edited config, so a
	// fresh install lost both — the capability-loss class ADR 0048 was written against.
	// Each active extra seat joins the box's `vllm_seats` roster with its own storeless
	// or store binding; the layers name it by id or alias.
	ExtraVLLMSeats []vllmseat.Spec `json:"extra_vllm_seats,omitempty"`
	// Composes lists the tiers this tier is a COMPLETE instance of at the same
	// time (ADR 0052: blackwell-3x16 composes blackwell-16 and blackwell-2x16).
	// It is seeded as `tiers` = Composes + the tier's own id and `tier_profile`
	// = the id, so health and status can advertise every tier the box is while
	// installed.json keeps ONE id and the matrix keeps one row per tier.
	Composes []string `json:"composes,omitempty"`
	// Layers are the device layers a composite box places work onto, seeded
	// VERBATIM into config.layers so at runtime everything reads config and a
	// box that seeds none is byte-identical on every surface. The pair layer's
	// agent seat may be declared bare and is derived from VLLMSeat at resolve
	// time (fillPairAgent), so the delegation seat's model, window, concurrency
	// and device pin live in exactly one place.
	Layers []config.LayerSpec `json:"layers,omitempty"`
}

Profile is the part of a profiles.json entry this package reads.

type VLLMSeatSet

type VLLMSeatSet struct {
	// Primary is the tier's lane seat (Profile.VLLMSeat); PrimaryActive says whether
	// this box runs it (Options.VLLMSeatActive).
	Primary       *vllmseat.Spec
	PrimaryActive bool
	// Extras are the tier's extra seats and ExtraActive which of them, by id, the box runs.
	Extras      []vllmseat.Spec
	ExtraActive map[string]bool
}

VLLMSeatSet is a tier's declared vLLM seats and which of them a box runs — the one input a layer resolution needs, shared by the seed (Resolve) and the render check (install render), so both reason about the same layers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL