Repository navigation
hive: dwarfstar, one bee per model, one GPU between them - #85
Merged
Merged
Conversation
This was referenced Oct 24, 2026
adiled
force-pushed
the
hive/dwarfstar
branch
from
October 24, 2026 14:42
1f3311b to
b036fef
Compare
A worker hive whose bee links antirez/ds4 into its own process and speaks thrum through the C client. A prompt tone becomes a chat prompt, the chat prompt becomes tokens, and the tokens come back as text_delta chunks and a finish, with no HTTP in between. The Makefile fetches ds4 at a pinned commit, compiles exactly the objects ds4's own Makefile links on macOS with its flags, includes thrum.mk for the client, libsodium and cJSON, and puts the Metal kernels beside the bee. install builds it and runs it under orchd like every bundled hive; the bee enters itself as main and signs its hello. One engine is resident at a time and keeps one session, synced to each turn's whole prompt so ds4 evaluates only what the KV cache lacks. Turns queue and run one at a time on their own thread; a cancel stops its sid's turn in flight and drops its queued ones. Sampling is seeded and uses ds4's defaults, the stop check is ds4-server's, a chunk carries whole UTF-8 characters, and a turn ends stop, length, cancelled or error. The bee claims one slot of headroom and is stateless. make check builds the bee against a stub bridge, so the thrum side runs with no model. Both were run through a humd built from this branch: the stub for queueing, cancel in flight and queued, and a character split across tokens; the engine with DeepSeek V4 Flash Q2 on an M5 Max for a real answer, a second turn on the resident engine, and a real cancel.
…n them The Orchfile now carries a unit per model, the way ds4-runner keeps a server per model: ds4flash, ds4flash-q2, ds41flash-q2 and glm53flash-q2. Each runs the same bee pinned to one GGUF (DWARFSTAR_MODEL, with the ids it answers to in DWARFSTAR_MODELS) and entered as the unit's name, so every model nestles with its own key, ids and headroom, and one can be exited without the rest. Model files are ARGs, since their names drift between machines. Each unit states its resources in the Orch spec: MEMORY, nice, SSD streaming and threads as ds4-runner ran them, RESTART on-failure with a start limit, and a stop timeout. install grows every unit; a unit whose model is not on the machine exits 0 and stays down. ds4 exits when a second process opens the GPU, so the bees share a hive-wide flock and hold it while their engine is loaded. A bee that needs the GPU files a want beside the lock and waits; the holder gives it back when idle and wanted, after its turn when a want has waited a minute, and after DWARFSTAR_IDLE_MS idle. A cancel ends a wait. Loading first checks ds4's own lock, so a ds4 started elsewhere is an error on the turn and not a dead bee. A bee claims one slot of headroom while the GPU is its own or free and pulses only when that changes; a probe that meets another bee's probe retries before calling the GPU taken. Run through a humd built from this branch: two stub bees traded the GPU on demand and on idle, a cancel ended a turn still waiting for the GPU, two idle bees sent no pulses in twelve seconds, and a missing model left its unit down. With the engine, a DeepSeek V4 Flash Q2 bee answered, then handed the GPU to a GLM 5.3 Flash Q2 bee, which loaded and answered.
openai-server sends a prompt's content as one flattened string, and hum-nest reads content as a string before it falls back to text. The bee only took text or content petals, so a chat completion through openai-server reached it and was answered "the prompt carried no text". It now takes a content string, then text, then content petals. Installed on a humd built from main, the four model units nestled as four bees, and an OpenAI chat completion to openai-server streamed back from the DeepSeek V4 Flash Q2 bee.
adiled
force-pushed
the
hive/dwarfstar
branch
from
October 24, 2026 16:30
70ff2cb to
3f6a7bc
Compare
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.
Stacked on #88 (the C client). This PR is only
hives/dwarfstar/.What this adds
A worker hive whose bees have the DwarfStar
engine linked into their own process and speak thrum through the C
client: one unit per model, each its own bee, sharing one GPU.
One unit, one model, one bee
The Orchfile keeps a unit per model, the way ds4-runner keeps a server
per model:
ds4flashdeepseek-v4-flash(ds4's default link)ds4flash-q2deepseek-v4-flash-q2ds41flash-q2deepseek-v4.1-flash,deepseek-v4.1-flash-q2glm53flash-q2glm-5.3-flash,glm-5.3-flash-q2Each unit runs the same
dwarfstar-bee, pinned to one GGUF and enteredas the unit's name, so each model has its own key, ids and headroom, and
hum bee <id> exittakes one model off the mesh. Model files are ARGs,since their names drift between machines. Each unit states its resources
in the Orch spec:
MEMORY,nice, SSD streaming and threads asds4-runner ran them,
RESTART on-failurewith a start limit, and a stoptimeout. A unit whose model is not on the machine exits 0 and stays down.
On macOS, launchd records
MEMORYas a soft resident-set limit thekernel does not enforce (the Orch spec calls it advisory there); systemd
enforces it as
MemoryMax. On a Mac, one model on the GPU at a time iswhat keeps memory in hand.
One GPU, handed between bees
ds4 exits when a second process opens the GPU, so the bees share a
hive-wide flock and hold it while their engine is loaded:
cancel ends the wait.
turn when a want has waited a minute, and after
DWARFSTAR_IDLE_MS.error on the turn, not a dead bee.
a peer routes to the model that can start now. It pulses only when the
claim changes. A local prompt still runs and waits for the handoff.
No arbiter: humd is the front door, and the handoff lives in the bees.
How a turn runs
One long-lived session per loaded engine, synced to each turn's whole
prompt so ds4 evaluates only what the KV cache lacks. Turns queue and run
one at a time; a
cancelstops its sid's turn, waiting or in flight, anddrops its queued ones. Sampling is seeded with ds4's defaults, the stop
check is ds4-server's, chunks carry whole UTF-8 characters, and a turn
ends
stop,length,cancelledorerror.Proof
Installed for real, on a humd built from main (
./install --edge)with
hum hive ./hives/dwarfstar install: the four model units nestled asfour bees, each under its own key, and an OpenAI chat completion sent to
openai-serverstreamed back from the DeepSeek V4 Flash Q2 bee (A beehiveis a structure where a colony of honeybees...). That run is what caught
openai-server sending
contentas a string; the bee now reads it.Through a humd built from this branch, in isolated XDG dirs:
answered Bees make honey. in 1.6 s, then handed the GPU to a GLM 5.3
Flash Q2 bee, which loaded (89 GiB planned) and answered A hive is a
structure, such as a beehive, in which honeybees live and store honey.
make check, no model): the GPU traded on demand and onidle, a cancel ended a turn still waiting for the GPU, two idle bees
sent no pulses in 12 s, a missing model left its unit down, and "é"
split across token pieces arrived whole.
orch validate. No undeclared keys in humd's speclog.
What changed from the first version of this PR
The first version carried its own C client, codegen and CI changes and
docs; #88 replaces those, so this is the hive alone. It also fixes what
the first version got wrong: the signature and
signedAtcame from twoclock reads; concurrent prompts shared one engine with no lock and
interleaved writes; it claimed
stateful_sessionwhile making a newsession every prompt; up to eight models could be held open at once; the
sampler was seeded with 0; a prompt with no model took whichever file was
listed first; and it advertised chis it did not handle.
Not here
The lattice (ds4 across machines), two models resident at once, vision,
tools and thinking, and CUDA: the Makefile wires ds4's Metal backend.