Repository navigation
feat(contract): berth contract ENGINE shows one engine's terms - #321
Merged
Merged
Conversation
One engine's terms in one place, each number tagged with where it came from: declared in berth.toml, Berth's default, measured, or unknown. It covers the priority, the VRAM a lease asks for (needs_mib, the learn_size size the broker would grant, or the whole card), the last run's peak, the RAM a run needs and holds parked, the minimum turn and window, and the gateway's median switch time per tier. A contract is a view over [[engine]] and berthd's status, with no file of its own, so it cannot drift from the config. Fit reads the same view next. The status reply's footprints now carry hot_peak_vram_bytes, ram_peak_bytes and parked_ram_bytes, and keep an entry that holds only those. A llama-swap model's own peak sits on its name's entry while the last run sits on the group's, so the model's entry was dropped before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Berth Next milestone 1c. The numbers that decide whether an engine fits are spread over three places today:
berth.toml, the broker's footprint book and the gateway's switch book. None of them says how far its number can be
trusted. Fit (milestone 2) needs those numbers in one place, each with its source. People need the same view when
they ask why a lease got the size it got.
What changes
New package
internal/contract.Build(name, *config.Engine, *proto.Status, *swapcost.Book)is pure andreturns a
Contract. Every number is a typed value with asource:declared: berth.toml sets it.default: berth.toml is silent, so Berth's default applies.measured: from the footprint or switch book.unknown: nothing declares it and nothing measured it.VRAM follows the broker's rule. It is
needs_mibif set (the largest card's value for a per-card list). Withlearn_sizeit is the measured peak plus 512 MiB, or the whole card when the peak fills it or was nevermeasured. Otherwise it is the whole card.
berth contract ENGINE [--config] [--costs] [--socket] [--format]. ENGINE can be an[[engine]]name, adiscovered engine, or a llama-swap model's
--asname. Without berthd it prints the declared terms and marksevery measured number unknown.
proto.EngineFootprintgainshot_peak_vram_bytes,ram_peak_bytesandparked_ram_bytes(all omitempty).footprintStatusnow keeps an entry that holds only those figures. A llama-swap model's own peak sits on itsname's entry and its last run on the group's, so the model's own entry was dropped before.
berth statusEST.VRAM ignores a zero
estimated_vram_bytes, the same way the harbor already did.A contract is a view with no file of its own, as the plan decided, so it cannot drift from berth.toml.
Proof
TestBuildVRAMcovers 8 sizing cases with literal sizes and reasons.TestBuildMeasuredAndDeclaredandTestBuildSwitchcheck the median of three samples, that hot is free by rule, and that a tier with no samplesis unknown.
TestFootprintStatusCarriesAModelsOwnPeakruns a real broker lease in group llama-swap. It fails with the oldLast == 0filter (the model's entry is missing) and passes with the fix.TestContractWithoutBerthdcovers the CLI JSON and human output, an unknown name, and flags after ENGINE.Writing it showed that
Parsestopped at the positional argument, so the command now usesParseInterspersed.berth contract comfyuishows priority foreground(declared), last peak 456 MiB (measured, 146 runs) and cold switch 8.0 s (median of 20).
berth contract stratashows min turn 5m (declared) and cold switch 73.0 s.proof.shfull passes.Not yet live: a llama-swap model's name (Dirk-27B) shows up once aphotic runs this build. A training run holds
the card right now, so berthd cannot restart.