Skip to content

feat(claims): hold only the cards a claim's gpu names - #272

Open
T-Crypt wants to merge 1 commit into
nextfrom
T-Crypt/claim-cards
Open

T-Crypt wants to merge 1 commit into
nextfrom
T-Crypt/claim-cards

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Oct 31, 2026

Copy link
Copy Markdown
Owner

A hold claim held every card on the node, so a game that runs on one card drained the engines on all of them. A [[claim]] now takes gpu, with the same card names and PCI addresses that berth run --gpu takes. Only those cards are held.

[[claim]]
name = "sim"
exe  = ["sim.exe"]
gpu  = "gpu1"

Changes

  • claims.Rule has GPU, the configured cards, and Cards, those cards resolved to positions in the node's cards. A nil Cards means every card. Compile refuses a bad card name and a gpu on a track claim, so berth config check refuses both.
  • berthd resolves each rule's gpu once at start (claimCards, with node.Pick). A name the node does not have is logged as an error, and that claim holds every card. A running game held on too many cards is safer than one held on none.
  • The watcher asks for the hold only on the rule's cards. Each card reports the claim active only where the claim holds that card, so berth claims and berth status name the right card.
  • node.View marks a claim inactive in a view of cards the claim does not touch. Before, View kept every claim as-is, so the gateway's background-engine check would see a game held on gpu1 and keep gpu0 idle as well. A claim with no cards, from an older berthd, still counts as on every card.
  • A claim without gpu holds every card, as before. The built-in pack is unchanged.
  • The CHANGELOG [Unreleased] section, docs/leasing.md, docs/gateway.md and the skill's claim example are updated.

Tests

  • TestWatcherHoldsTheCardsItNames puts a rule naming gpu1 and a rule without cards on three cards. Only gpu1 is asked for the first rule, and only gpu1 reports it active. Every card holds the second rule.
  • TestClaimCardsResolvesTheRulesCards resolves by name and by an nvidia-smi-form PCI address, and checks that a card the node lacks is logged and falls back to every card.
  • TestViewIsTheCardsAKeyNames now has a claim on gpu1. The claim is active in views that include gpu1 and inactive in a view of gpu0 alone.
  • TestClaimGPUKeyValidated and TestCompileRejects cover the config errors.

I broke the code five ways, one per piece. Asking for every card, reporting the claim on every card, skipping the compile check, skipping the startup resolution, and skipping the View narrowing each fail the matching test.

Full proof: go build, gofmt, go vet, the Windows build and vet, golangci-lint (0 issues) and go test ./..., all green. berth config check from the built binary accepts gpu = "gpu1" and refuses "card 1" and a gpu on a track claim. The multi-card path is tested against fakes and the in-process node only, because no multi-card host was available.

A hold claim held every card on the node, so a game pinned to one card
drained the engines on all of them. A [[claim]] now takes gpu, the same
card names and PCI addresses berth run --gpu takes. berthd resolves it
to the node's cards at start and asks for the hold on those cards only;
a name the node lacks is logged and the claim holds every card. Each
card reports the claim active only where it holds, and node.View marks
a claim inactive in a view of cards it does not touch, so the gateway
starts background engines on the free cards. A claim without gpu holds
every card as before.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant