Core
Sharding and gangs
Split a model across several machines with llama.cpp RPC, vLLM on Ray, or SGLang, run several gangs of one model, and read the failure codes.
In short
A gang is one complete serving copy of a model split across several machines: N parts plus one coordinator, the process that serves the API for the whole gang. Use a gang when a model is larger than any one worker. opod shard create forms it and the router sends the model's requests to its coordinator. Several gangs of one model add throughput.
Have enough ready workers
opod node lsEach worker that hosts a llama.cpp part needs
rpc-serveronPATH(see Prerequisites).Create the gang
opod shard create llama-3.3-70b-sharded # opod picks the part count opod shard create llama-3.3-70b-sharded 2 # two parts on two picked workers opod shard create llama-3.3-70b-sharded --nodes n_a,n_b▶ creating sharded model llama-3.3-70b-sharded on [n_a n_b] (this may take a few minutes)… ✔ sharded model ready: llama-3.3-70b-shardedopod model addon an entry withsharding.required: truerunsshard createfor you.Send it a request
curl http://localhost:8080/v1/chat/completions -H "Authorization: Bearer $ADMIN" \ -H 'Content-Type: application/json' \ -d '{"model":"llama-3.3-70b-sharded","messages":[{"role":"user","content":"hi"}]}'Remove it when done
opod shard remove llama-3.3-70b-sharded
Check it worked
opod shard lsMODEL GANG ROLE NODE ADDRESS STATUS
llama-3.3-70b-sharded g0 coordinator n_a 192.0.2.51:9001 ready
llama-3.3-70b-sharded g0 rpc n_a 192.0.2.51:50052 ready
llama-3.3-70b-sharded g0 rpc n_b 192.0.2.52:50052 readyEvery row reads ready, and the gang has a coordinator row. GET /v1/models lists the model.
Backends
The catalog entry's sharding.engine picks the scheme. An entry with no engine uses llamacpp.
sharding.engine | Scheme | What runs on each machine | Parallelism |
|---|---|---|---|
llamacpp | llama.cpp RPC, layer split | an rpc-server per part, plus one llama-server --rpc coordinator | layers only; --tp above 1 is refused |
vllm | a Ray cluster | a Ray daemon per part; vllm serve … --distributed-executor-backend ray on the head | --tp and --pp |
sglang | SGLang's own multi-node launcher | python -m sglang.launch_server on every machine with --dist-init-addr, --nnodes, --node-rank; rank 0 serves the API | --tp over the whole gang, --pp for stages |
A create with expert: true (admin API only) on a vllm entry runs vLLM expert parallelism: one vllm serve per part with --enable-expert-parallel and vLLM's data-parallel ranks, no Ray. pp is refused for that shape.
When a vLLM or SGLang gang is ready
A vLLM or SGLang create returns as soon as every part is launched. The head's API comes up later, after every part has joined and the weights are loaded. On a 1.5B model across two machines that took 45 s (vLLM, pipeline 2) to 2 min 20 s (SGLang, tensor 2).
From core v0.4.2, the coordinator row reads starting until the head answers GET /v1/models. The leader asks every 5 s and then stores ready. Until then the router does not send it requests, /readyz fails, GET /v1/models does not list the model, and a request gets 503 with "is not ready to serve yet". Wait for the row:
opod shard ls # the coordinator row: starting → readyOn the design-partner cell (two RTX 3060 Ti machines, Qwen2.5-1.5B), the row read starting for about 2 min 20 s (SGLang, tensor 2) and 73 s (vLLM, pipeline 2), and then every request answered.
Older cores get this wrong:
- Core v0.4.0 stores the row
readyat launch. Requests get503until the head loads, while/readyzand the control plane say the gang serves. - Core v0.4.1 waits for the head, but in the second before the row turns
readya request can get502, and/v1/modelslists the model while it loads. - Core v0.4.0 and v0.4.1: an SGLang gang across machines stops serving about 30 s after it starts. The worker of every rank but 0 stops reporting when SGLang opens a placeholder health server on its engine port. The leader then reads the part as silent, and every request gets
503"1 part(s) whose engine stopped answering". Use core v0.4.2.
A llama.cpp gang is ready when its create returns: the create waits for the coordinator.
Rules shared by every backend:
tp × ppmust equal parts × devices per part.tpmust be a multiple of the devices inside one part.- With neither given: tensor parallel inside a machine, pipeline parallel across machines.
- A tensor-parallel group wider than one machine is allowed and logged as a warning. Every all-reduce of every token then crosses the network; pipeline parallel is the cheap shape on ordinary Ethernet.
Refused by name
An SGLang pipeline (pp > 1) of a Llama-family model with tied word embeddings crashes SGLang's last stage. Opod reads the model's config.json first and refuses the create with 409 and error.code: sglang_pp_tied_llama. Use tensor parallel, one stage, or sharding.engine: vllm.
Splitting one model across cards and machines
Each dot is one token's traffic on that link
shardGroups:
- id: g0
engine: vllm
head: node-a
parallelism: { pipeline: 2 }
parts:
- { node: node-a, vramBudgetGb: 20 }
- { node: node-b, vramBudgetGb: 20 }Prerequisites for llama.cpp RPC
rpc-serveronPATHon every worker that hosts a part. The Homebrew bottle does not include it; build llama.cpp with-DGGML_RPC=ON, or use anopod-worker-llamacpp-*image, which carries the pair.llama-serveronPATHon the machine that runs the coordinator.- A catalog entry with
sharding.required: true, and eithersource.type: filewith asource.paththe leader can read, orsource.type: huggingfacewith asource.file. - Enough workers in state
ready.
The leader distributes the weights: it downloads a Hugging Face GGUF into its models directory, then uploads the file to each part's worker over /v1/process/upload after a SHA-256 check. A worker that already has the file is skipped.
How a llama.cpp gang forms
- The leader picks the workers, and refuses with
409(and the numbers) when it cannot find enough. Nothing is torn down or started. - It starts
rpc-server -p <port>on each part through the worker's/v1/process/startand waits for the port. Ports start atsharding.rpc_port_base(default50052). - It starts the coordinator,
llama-server -m <gguf> --rpc <part1>,<part2> --port <coordinator_port> --metrics, and waits for it. - It stores the gang's rows and a placement for the model.
- The router sends every request for the model to a ready coordinator.
If a part fails to start, every process the create started is stopped and the error is returned.
Part count
With no count, no --nodes, no --tp and no --pp, the CLI picks the shape: the smallest number of equal parts that fits the live workers' free memory. One part when the model fits one worker. Never more parts than live workers, or than the model's layers when the catalog records architecture.layers. It prints what it picked and why, and refuses with the numbers when nothing fits.
Free memory is each worker's registered card memory (else RAM), minus the reserve, minus what it already holds. A worker's --vram-budget is not reported to the leader, so name the count yourself when workers share a card.
Any shape you name is sent unchanged. The admin API never picks: a body without nodes or shards uses the catalog's default_shards.
Without --nodes, parts go to the strongest workers: a worker with a card before one without, then the bigger card, then the bigger host. With --nodes, parts go where you name them, in that order.
How opod shard create picks the parts
Model size against live workers' free card memory; equal parts, strongest workers first
llama-server --rpc …) goes on n_a, the part with the most card memory, because it holds the KV cache. Where the coordinator runs
The coordinator holds the KV cache, so it runs on the gang's worker with the most card memory (host RAM for a worker without a card). It runs on the leader only when the gang has no workers. To choose:
OPOD_COORDINATOR_NODE=<node id>on the leader pins it;localforces the leader.headinPOST /admin/v1/shards/createnames the worker rank.head: "local"is refused.
A one-part gang runs the whole model on that worker with no rpc-server; the coordinator override is ignored.
Several gangs of one model
A second gang is more throughput, not a bigger model. Each gang serves whole requests; the router picks the least-loaded gang whose coordinator is ready. In core v0.4.6 that choice is load alone: a conversation's pin, the prefix pin and the route token are not read for a gang. From core v0.4.7 gangs are ranked like workers: a later turn of a conversation, or a prompt whose lead a gang served, stays on that gang while it has a free slot.
opod shard create llama-3.3-70b-sharded --nodes n_a,n_b # the default gang, g0
opod shard create llama-3.3-70b-sharded --gang g1 --nodes n_c,n_d # a second copy; g0 keeps serving
opod shard remove llama-3.3-70b-sharded --gang g1 # only g1A create without --gang replaces every gang of the model. A remove without --gang removes them all. The API half is DELETE /admin/v1/shards/{model_id}/{gang_id}.
Every judgement is per gang: one gang losing a part takes only that gang out of rotation.
Uneven splits
A llama.cpp gang can weight its split towards a bigger card with the tensor_split engine flag, for example 12,8. The gang's flags reach the coordinator. vLLM and SGLang accept pp_layer_partition, but a multi-machine split with it is not proven on those engines.
Failures and recovery
- After a create succeeds, a crashed
rpc-serveror coordinator restarts up to 5 times, with back-off of 1, 2, 4, 8 and 16 seconds. Then the process is in statecrashloopand stays there until you act, usually with anothershard create. - A Ray-backed vLLM coordinator starts without automatic restart.
- In managed mode, the leader re-forms a gang that its plan declares and that has had no parts left for 45 seconds, once free workers register. After a failed attempt it backs off 15 s, then 30 s, then 60 s, and records
shard.heal_failed. After 3 failed attempts at the same gang shape it gives up (final: true) until the gang appears or the plan changes its shape. See Plan file.
POST /admin/v1/shards/create errors carry error.code:
| Status | error.code | Meaning |
|---|---|---|
404 | — | No catalog entry for model_id. |
409 | — or a reason code | The workers for the shape cannot be found, or the engine cannot run it. Nothing was touched; the gang being replaced keeps serving. |
409 | sglang_pp_tied_llama | See above. |
502 | gang_part_lost | A part's worker went away while the gang formed. The gang did not form; its parts were stopped. |
502 | gang_part_failed | A part's process reported failed or crashloop. The message carries the engine's last lines. |
502 | gang_create_in_flight | Another create of this gang (or the whole model) is running. Says nothing about the gang itself. |
Key on error.code, not the message.
If it fails
| Symptom | Fix |
|---|---|
opod: cannot pick a shard count for … no split fits … | Free memory on the workers, join more workers, or name the count yourself. |
tp=2: llama.cpp RPC sharding is layer-wise only and has no tensor split … | Drop --tp, or use an entry with sharding.engine: vllm or sglang. |
409 sglang_pp_tied_llama | Use tensor parallel, one stage, or sharding.engine: vllm. |
502 gang_part_failed | Read the engine lines in the message and opod shard ls; on llama.cpp, check rpc-server is on PATH. |
502 gang_create_in_flight | Another create is running. Wait, then opod shard ls. |
A part shows crashloop | It crashed 5 times. Fix the cause, then run opod shard create again. |
The gang has parts but no coordinator row (an interrupted create) | opod shard remove MODEL --gang ID --yes, then create again. |
What a gang reports
/loadz takes a gang's KV-cache use, queue depth and token rate from its coordinator, because the parts run no engine of their own. One coordinator sample counts once in reporting. See Probes.
Not supported
- Moving or rebalancing a live gang. Rebuild it with
shard create. - Changing the part count of a live gang.
Last updated · Source: content/docs/core/sharding.mdx · View as Markdown