From the README at v0.1.5, linked from the repository
shep-paddock
A shep dog that leases one host’s GPU and RAM to model servers and jobs, behind a single endpoint.
A dog for shep on a host where several model servers share one GPU. Clients name a model at one endpoint; the dog starts and stops the sheep that serve it, following rules about which models can run together, queues requests that do not fit yet, and lets long jobs hold a lease so nothing evicts them.
Use
cargo install shep-paddock
shep adopt shep-paddock
The dog asks for the shepherd channel, and the shepherd stops it with a message rather than a signal; a dog adopted before this version gets the channel at the next shep adopt shep-paddock.
Then add a [paddock] section to dogs.toml in $SHEP_HOME. This one serves a model from a sheep called llama:
[paddock]
listen = "0.0.0.0:8700"
[paddock.host]
vram = "24564M"
ram = "63439M"
[[paddock.clients]]
name = "bench"
key = "change-me"
[paddock.models.llama]
backend = { sheep = "llama" }
url = "http://127.0.0.1:8080"
ready = { path = "/health" }
apis = ["openai"]
vram = "20G"
idle = "2h"
-
The sheep must already be in the flock.
shep add ./serve.sh --name llamaregisters it without starting it. -
A change made through shep applies at once, and an edit made to
dogs.tomloutside shep applies within 30 seconds. -
A change to a sheep model’s launch settings, its backend
env,argsorscript, a placement’senv,argsorscript,sequences,turn_ramorcontainer, reaches a model that is already loaded once nothing would be cut off: no lease holds it, no request is in flight on it, no request or lease waits for it, it has gone unused for thegraceperiod (120s by default), and it fits at its new figures. The dog then unloads it and loads it again, keeping its reclaimable leases. Until then it counts for the larger of its old and new figures, and the status marks itSTALE. Other settings, such asidle,excludes,prefixandapis, apply at once without a reload, and an ollama model has no launch settings. -
Sizes are
1G,512Mor64K, durations are120s,5mor2h. -
A model with
vram = "all"takes the whole GPU.excludesnames models that cannot load beside it, and models on one sheep never load together. -
A model on ollama points
backendat a[paddock.backends.*]entry ofkind = "ollama". The dog removeskeep_aliveandoptions.num_ctxfrom what it forwards there, because it decides what stays loaded and the model’snamefixes its context. For the same reason an ollama request that only asks to unload a model gets a403. Responses come back as the backend sent them, so theirmodelfield carries the backend’sname, not the name the client asked for. -
A sheep model may set
nametoo, for a server that knows the model by another name. A request’smodelis rewritten to it, and nothing else in the body changes. -
apissays which routes reach a model:openai(/v1/chat/completions,/v1/completions,/v1/embeddings),anthropic(/v1/messages), andollama(/api/chat,/api/generate,/api/embed,/api/embeddings). -
docs/brainstorming/specs/2026-10-04-slice-1-design.mdhas every field. -
A model on a sheep may declare
[[paddock.models.<name>.placements]]instead ofvramandram. Each placement has aname,vram,ramand any ofscript,argsandenv. The dog tries them in order when the model loads and never moves a running one. This one runs on the GPU when it fits and falls back to RAM:[[paddock.models.laya.placements]] name = "gpu" vram = "6G" ram = "2G" script = "/path/to/venv-gpu/bin/laya-serve" env = { LAYA_DEVICE = "cuda", CUDA_VISIBLE_DEVICES = "0" } [[paddock.models.laya.placements]] name = "ram" ram = "5G" script = "/path/to/venv/bin/laya-serve" env = { LAYA_DEVICE = "cpu", CUDA_VISIBLE_DEVICES = "" } -
docs/brainstorming/specs/2026-10-06-slice-2-design.mdhas every field of slice 2. -
sequencessays how many leases a model’s backend serves at once:1for a server that runs one sequence and caches one prompt, its slot count for a llama-server. A lease past it waits its turn, with a reason naming the holders and its place in line. Each turn has one request in flight, and the rest of its holder’s requests wait. Requests under no lease, and under a reclaimable one, share one more request turn. Bare and reclaimable leases take no turn. Unset means no limit, and every request is forwarded at once. -
Three request headers steer a request, and none reaches the backend.
X-Paddock-Priority: batchqueues it behind interactive requests (interactiveis the default).X-Paddock-Max-Wait: 90sreplaces the config’smax_waitfor that request.X-Paddock-Lease: L12names the lease whose turn the request takes, for a client that holds several leases on a model and needs to say which conversation a request belongs to. It counts when the lease is live, the client’s, on the requested model, and not reclaimable. If that turn is busy the request waits for it and no other turn. Any other lease id is passed over, and the request takes a turn as if the header were absent. A value that is not a lease id as the lease routes show it is400withbad_lease. -
admin = trueon a[[paddock.clients]]entry lets that client revoke a lease, unless a protected client other than itself holds it.protected = truekeeps a client’s leases from every other client’s revoke, admin or not. -
A model on a sheep may name
container = "<podman container name>"when its sheep starts a podman container. The dog measures the container’s processes with the model’s, counts a container running without its model as a stray, and stops the container after its sheep:[paddock.models.iq3_xxs] backend = { sheep = "iq3_xxs" } container = "strata-qwen-iq3_xxs" -
A model with
sequencesmay declareturn_ram, the RAM one conversation holds while its backend keeps it warm, in the same size grammar asram. The backend keepssequences + 1conversations, one per lease turn and one for the request turn, and the footprint counts all of them:ram + (sequences + 1) × turn_ram.ramis then the model holding no conversation. On a model with placements,turn_ramis added to each placement’sram. Admission, the fit check at load and the status all use the total. The sheep is told the numbers before it starts, asPADDOCK_SLOTS(sequences + 1) andPADDOCK_TURN_RAM_MIB(turn_ramin MiB, rounded up), set after the model’s ownenv.turn_ramwithoutsequences, or on an ollama model, is refused when the config is read. Here the footprint is 41G + 3 × 4G = 53G:[paddock.models.iq3_xxs] backend = { sheep = "strata", env = { MODEL = "IQ3_XXS", FAMILY = "qwen", IMAGE = "localhost/strata" } } container = "strata" sequences = 2 turn_ram = "4G" ram = "41G" vram = "all" -
A sheep model may set
metrics = "strata", which says its backend is Strata. While the model is loaded, the dog reads itsGET {url}/metricsat each report, with the model’skeyas the bearer when it has one, and sends the figures to the metrics dog labelled by model. Strata’s own numbers would otherwise vanish with each model swap, and its/metricsis JSON.metricson an ollama model is refused when the config is read. It is not a launch setting, so changing it never makes a loaded modelSTALE. The series are under Metrics. -
A
[paddock.meter]table makes the dog read the host’s power, so the energy it uses can be counted. Without the table nothing is read, and the readings are taken whether or not a metrics dog is listening. Admission is unchanged: it counts declared footprints only.[paddock.meter] kasa = "192.168.1.40" outlet = 3 every = "5s"kasais the host or address of a TP-Link Kasa plug or strip with an energy meter (HS300, KP115, KP125, EP25), asked on its local port 9999. A read that takes over a second is skipped.outlet, 0 to 5, is the HS300 outlet the host is plugged into. Leave it out for a single plug.everyis how often to read,5swhen absent.- Without
kasa, the dog adds the GPU’spower.drawfromnvidia-smito the CPU package’s power from/sys/class/powercap/intel-rapl:0/energy_uj. That leaves out RAM, the board, the fans and the power supply’s loss, so it is reported under its ownmetervalue,parts, and a plug’s iswall. Linux lets only root read the counter by default, so for another user the CPU goes unread and so does the whole reading. The GPU read waits up to a second for the survey’snvidia-smito end, and the survey waits for it the same way. Past that the earlier one is taken as stuck and the read is skipped. - A read that fails is skipped, never counted as 0 W, and the dog logs its reason once until a read succeeds. A change to the table applies at the next restart.
-
Energy becomes a cost with a price, which the same table can give. The status shows it, and the metrics dog gets it.
[paddock.meter] usd_per_kwh = 0.17 # or, to look it up from where the host is: eia_key_env = "EIA_API_KEY"usd_per_kwhis the price from the maintainer’s bill, in US dollars. It wins when set, and nothing is looked up.eia_key_envnames the variable in the dog’s environment that holds a free EIA API key. With it and nousd_per_kwh, the dog asksipinfo.io/json(no token) where the host is. For a US host it asks EIA’s retail sales for its state’s average residential price in the latest month EIA has, in cents per kWh, and divides by 100. Outside the US the host is unpriced.- EIA’s state average stands in for the host’s own tariff, whose tiers and time-of-use rates do not reduce to one figure, so set
usd_per_kwhfor a price that is the host’s. EIA’s data runs two to three months behind. A host’s place comes from its public address, so a VPN or a hosted address names the wrong state. - A looked-up price is kept with its month and read again after 7 days. A lookup that fails keeps the last price, logs its reason once until one succeeds, and is tried again within the hour. The key is read from the environment when a lookup needs it, and it is never logged or shown in the status.
- With neither key the host is unpriced, and energy is still metered. A change to the table applies at the next restart.
GET /paddock/statusshowsprice: { usd_per_kwh, source, region, period }, wheresourceissetoreia, andregionandperiodare null for a set price. It isnullwhile the host has no price.
-
With a meter, a released lease says what it used.
- Each reading’s energy, its watts times the seconds since the last reading, is split evenly among the leases whose holder has a request for the lease’s model in flight or queued. With none, it counts as idle. It is the host’s whole draw, not only the part above idle, so a lease carries its share of keeping the host on. A bare lease runs no requests through the dog and is never given a share.
- Each lease adds up its own watt-hours and, where the host is priced, its dollars at the price of each reading.
DELETE /paddock/leases/{id}still answers 204, and addsPaddock-Energy-Wh(such as12.345),Paddock-Energy-Usd(such as0.001234, absent while the host is unpriced, and for a lease that used energy before the host had a price) andPaddock-Energy-Source(wallorparts). With no meter read yet none of the three is sent.GET /paddock/statusshows each lease’senergy_whso far, left out while no meter has been read.- A lease restored after a restart starts its energy again from 0. The saved state is unchanged.
Clients send Authorization: Bearer <key> to the one endpoint. A request names its model in the body, or reaches it through the model’s prefix. If the model is not loaded the request waits while the dog frees room and starts it. GET /v1/models lists the models and needs no key, and GET /api/tags lists the ones on ollama’s API the same way.
Hold a model for a long job with shep paddock run. The lease lasts until the command exits, and nothing evicts the model meanwhile:
export PADDOCK_KEY=change-me
shep paddock run --model llama --expected 8h -- ./benchmark.sh
A lease waiting for a model that needs the loaded one evicted holds back newer leases on the loaded model, so its held leases can all end and the swap happen. Leases already granted keep their turns, a lease that is ahead in the queue is still granted, and requests with no lease are not held back. A held-back lease’s reason is behind, naming the model the waiter ahead waits for.
PADDOCK_URL sets the dog’s address and defaults to http://127.0.0.1:8700. Without PADDOCK_KEY the key comes from shep’s secret store, so on a host running shep it can be set once with shep secret set PADDOCK_KEY --stdin.
Two flags change how long the lease lasts. --release-if-idle 30m ends it once the lease’s own client has sent the model no request through the dog, and no note has come, for that long. Other clients’ requests do not count, and a request still running keeps the lease in use. --reclaimable keeps the model loaded without holding it, until something else needs the room. Inside the command, shep paddock note "step 412/900" says the lease is in use.
A job that runs its own GPU code can lease memory instead of a model:
shep paddock run --vram 12G --ram 4G -- ./train.sh
It waits like any lease and may evict a reclaimable model for the room. Nothing evicts it. Run on the GPU host with $PADDOCK_URL naming a loopback address, as the default does, the dog measures the job’s GPU memory. The command runs in its own process group, so it should not read the terminal. If an admin revokes it, the whole group gets SIGTERM, then SIGKILL after --grace (30s), and the lease is held until every process in the group is gone.
An admin client’s key ends a lease with shep paddock revoke L12 --reason "forgotten since Tuesday", unless a protected client other than itself holds it. A model lease’s command runs on. A bare lease’s command is stopped. The dog’s log records who revoked what and why.
A waiter’s reason comes with reason_kind, one word a client can match on: loading, evicting, draining, grace, held, behind or turn. It is on the lease stream’s queued lines, in a 503 body and in the status.
Status
shep paddock status prints GET /paddock/status, which needs a key. It prints the host’s totals and declared footprints, each model’s state, the leases, the queue, and the last 20 failed loads, as tables. Sizes are in binary units (KiB, MiB, GiB). The JSON endpoint reports them in bytes.
Slice 2 adds columns. The models table shows each model’s PLACEMENT, and DRIFT says yes when it measures more than 10% above what it declared. The leases table shows how long each lease has been IDLE and whether it is RECLAIMABLE. When the survey can read the GPU, a line under the host table gives the GPU memory that nothing the dog knows of holds, as unaccounted VRAM. The JSON carries more: whether a model is a stray, loaded by something other than the dog, and the figures measured for it. docs/brainstorming/specs/2026-10-06-slice-2-design.md names every field.
Slice 3 adds more. A bare lease shows its footprint in place of its model, its measured VRAM (MEASURED) and DRIFT. REVOKED-BY names who revoked a bare lease while its job may still run.
Slice 4 adds a FOOTPRINT column to the models table, the VRAM and RAM each model counts for against the host. all stands for a model that takes whatever VRAM is free. A bare lease’s footprint reads the same way, and a waiting bare lease shows its footprint in place of its model in the waiters table. The JSON gives each footprint as bytes with vram_all, and vram_bytes keeps the host’s VRAM for all.
Slice 4 also adds MEASURED, PEAK and TURNS to the models table. MEASURED is what the last survey read the model holding, and PEAK the highest RAM and VRAM any survey has read since the model last loaded, each as {vram} VRAM, {ram} RAM with - for a figure not measured. The peak restarts at each load, so one from an earlier config never shows under a new one, and it is reported only: admission and DRIFT ignore it. TURNS reads 2 lease + 1 request for a model with sequences = 2, the extra slot being the request turn the backend keeps, and - without sequences. The JSON adds measured_peak, turn_ram_bytes (null when unset) and turns to each model.
Slice 4 also adds LEASE to the waiters table, the lease whose conversation a waiting request is in, as L12, so a slow answer shows why. It reads - for a request on the request turn, a request on a model without turns, a request waiting for the first of several of its client’s leases to free, and a lease waiter. The JSON gives it as lease on each waiter, null in those cases.
Slice 4 also adds STALE to the models table: yes for a loaded model whose launch settings the config has since changed, - otherwise. A stale model keeps its loaded state until the reload starts, then STALE goes back to - as the state moves to unloading. The JSON adds stale to each model.
Lookout pane
Lookout draws the dog’s status from its pane, so an operator reads the host and its models, and ends a lease, without shep paddock status or an admin key:
hostshows the VRAM and RAM the models and bare leases declare, out of the host’s totals, and the VRAM nothing the dog knows of holds when the survey can read the GPU.modelshas a row for each model with its state, the VRAM and RAM it counts for, its requests in flight, the clients holding it and when it was last used.leaseshas a row for each granted lease, keyed by its id, with its client, model, state and start. A revoked bare lease still listed readsrevoked.
End a lease on a row revokes it, after lookout asks. It is the same call as shep paddock revoke, recorded as <operator> in the log and the status (a client cannot have that name), and it takes no admin key because lookout acts as the operator. A protected client’s lease is still refused, and so is a row that names no lease.
The pane shows the book as of the last report, up to 15 seconds old, and a revoke refreshes it. It needs the shepherd’s channel, as the metrics do.
Metrics
The status shows the queue only when it is asked. The dog also reports three gauges to the shepherd every 15 seconds, so the host’s metrics endpoint keeps their history:
paddock_model_loaded{model}: 1 while the model is loaded, 0 in any other state. Every model the status lists is reported, strays included.paddock_leases{model}: granted leases on the model. A revoked bare lease still listed is not counted. A bare lease counts with nomodellabel.paddock_waiters{model, reason_kind}: requests and leases waiting, by the word the status gives asreason_kind. A request waiting for its turn counts underturn, and a waiter not yet told a reason undernone. A bare lease waiter has nomodellabel.
With [paddock.meter] and a metrics dog listening, these are sent at each read, labelled meter (wall or parts):
paddock_power_watts{meter}: the host’s power at the last good read.paddock_energy_joules_total{meter, model, use}: a counter of watts times the seconds since the last good read, so a failed read’s gap is counted at the next good one’s power. The first read adds nothing.useisleasefor energy split among the leases ofmodelthat had a request in flight, andidle, with nomodellabel, for energy no lease used.
The label is meter, not source: the metrics dog writes sheep, id, fold, dog and source on every sample itself, and refuses a sample that sets one of them.
With a price, paddock_electricity_usd_per_kwh is sent beside the dog’s own series. It has no labels and is absent while the host is unpriced.
A sheep model marked metrics = "strata" also has its backend read while it is loaded, each series labelled model. Counters come from Strata’s totals, and Strata sets them back to 0 when it restarts, which the metrics dog reads as a counter reset:
paddock_strata_requests_total,paddock_strata_prompt_tokens_total,paddock_strata_reused_tokens_total,paddock_strata_output_tokens_total,paddock_strata_drafts_offered_totalandpaddock_strata_drafts_accepted_total.paddock_strata_prompt_seconds_totalandpaddock_strata_decode_seconds_total: Strata’sprompt_msanddecode_msin seconds.
Gauges come from live and hardware:
paddock_strata_queuedandpaddock_strata_tokens_per_second, which reads 0 while Strata is not generating.paddock_strata_state{model, state}: 1 for the state Strata reports amongreading,generating,idleandunloaded, 0 for the others, and 0 for all four when Strata reports a word not among them.paddock_strata_gpu_utilization_percent,paddock_strata_gpu_memory_used_bytes,paddock_strata_gpu_temperature_celsiusandpaddock_strata_gpu_power_watts.
A field Strata leaves out or sends as null has no sample, except tok_s, which reads 0 when it is null. A field the dog does not know is ignored. A scrape that is refused, takes more than 2 seconds, answers anything but 200 or answers something that is not Strata’s JSON sends no Strata series that round, and the dog logs one line for the model and no more until a scrape of it succeeds or it stops being loaded or marked. The dog’s own series above are sent first, so a stuck backend never delays them. When the model stops being loaded or marked, its Strata gauges are sent once at 0 like the label sets above. So is a gauge that a later scrape leaves out or sends as null, such as the state or gpu_power, while the model stays loaded. Its counters are not, since a counter that falls reads as a reset.
A label set that was reported and is gone, because its count fell to nothing or its model left the config, is sent once more at 0 and then dropped. The metrics dog keeps a series’ last value until the dog restarts, so without that zero the old count would show on.
This needs a shep whose metrics dog serves channel samples. Under any other, or a dog started by hand, nothing is reported.
assets/grafana/paddock.json is a Grafana dashboard for these series, with a Host variable for more than one paddock. Import it and pick the Prometheus data source that scrapes the metrics dog.
Security
SECURITY.md says what the dog promises and what it does not.
License
MIT OR Apache-2.0, at your option.