Repository navigation
feat: a size per card for a model split across cards - #291
Merged
Merged
Conversation
A model split unevenly across cards (llama.cpp --tensor-split 3,1) needs a different amount on each. needs_mib and berth run --needs-mib took one size for every card, so the lighter card reserved as much as the heavier one and nothing else could use the room left on it. needs_mib now reads a number or a list (needs_mib = [18000, 6000]), and --needs-mib reads "18000,6000", one size per card in the order gpu names them. The run sends the list as needs_each and the largest size as needs, so a berthd that predates needs_each reserves too much on the smaller card, never too little. berthd refuses a list that does not match the cards, and each card's share of the lease reserves its own size. One value sizes every card, as before, and writes back as a plain number.
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.
Refs #289
#289 asks how Berth handles a llama.cpp model split across several cards with
--tensor-split. Most of it already worked.berth run --gpu gpu0,gpu1holds one lease on both cards, grants them together, and starts the engine withCUDA_VISIBLE_DEVICESin the order named. The gap was sizing:--needs-mibwas one size for every card, so with an uneven split the lighter card reserved as much as the heavier one.docs/design.mdalready describes "a lease that covers several cards with a size on each". This makes the code match it.What changes for users
needs_mib = [18000, 6000]on an engine entry withgpu = "gpu0,gpu1", orberth run --needs-mib 18000,6000, reserves 18000 MiB on gpu0 and 6000 MiB on gpu1. The room left on gpu1 can serve another engine without a drain.berth run, and in berthd.docs/leasing.mdhas a new section, "Split one model across cards", with a llama.cpp--tensor-splitexample and how to size each card fromberth status.How it works
config.MiBsis the size list. It reads a number or a list in TOML, JSON and YAML, and18000,6000on the command line.needs_eachcarries the list andneedscarries the largest size. A berthd that predatesneeds_eachreads onlyneeds, so it reserves too much on the smaller card, never too little.AcquireAllandReattachAllbuild each card's share from its own size, so a re-attach after a berthd restart keeps the sizes.berth runit starts.Proof
go test ./...under America/Los_Angeles and UTC, the Windows build and vet, and golangci-lint (0 issues) all pass.berth run --gpu gpu1,gpu0 --needs-mibwith two sizes against a real berthd with two cards. Each card's share holds its own size, in the order named. Two sizes for one card are refused with exit 75.