Serve 11 local models from one endpoint

One endpoint, two GPUs, eleven models — swap on demand

Header plate for the model orchestrator: decision flow from an OpenAI-compatible request on one endpoint at port 8010 through the resident? and slot idle? checks to SERVE, SWAP-LOAD or a 503 wait, beside two equal GPU-slot cards (GPU 0 and GPU 1, each running qwen3.8-flash-next via Strata) with serve and swap arrows into both, notes that the two instances share one expert arena in RAM and served models never move, and Strata backend and llama.cpp backend chips.

Eleven models, two GPUs, one OpenAI-compatible endpoint on port 8010, no cloud. This post describes the orchestrator that serves all of the installed models. The technology is unremarkable: a FastAPI proxy and a JSON registry. The code itself is published: ByteCreation/orchestrator (MIT).

The shape of it

A Python FastAPI service, running as a systemd unit, listens on :8010 and owns two child llama-server processes, one slot per GPU, on localhost ports 8011/8012. Clients only ever talk to 8010. Models live in registry.json: weights path, context size, KV-cache quantization, batching, sampling, reasoning flags, and which GPUs the model fits on. Serving a model means having it loaded in a slot. The orchestrator’s task is deciding which slot holds what, and when.

SlotGPUChild portBoot default
00127.0.0.1:8011qwen3.8-flash-next (Strata)
11127.0.0.1:8012qwen3.8-flash-next (Strata)

Child servers are localhost-only. Only the proxy faces the network. One model per slot at a time. The runtime backend follows the registry entry, normally llama-server, but the flagship entry declares "backend": "strata" and the orchestrator starts Strata Terminal as the slot child instead, with the same swap lifecycle.

Routing and swap rules

  • Requested model already loaded? Served from that slot. With several matching slots, the least-busy one wins, ties round-robin.
  • A ready slot that is only momentarily busy (empty queue, <2 active requests) continues-batches the request.
  • Congested (≥2 active or queue backlog) and another slot idles on a different model? That idle slot swaps to the requested model.
  • No slot available? Queue, up to 300 s (ORCHESTRATOR_QUEUE_TIMEOUT), then a clean HTTP 503.
  • Swap = kill the old child, wait for VRAM to drain below ~1 GiB, start the new model, wait for its /health. A child that dies during boot fails the swap immediately instead of timing out.
  • Upstream errors (e.g. context exceeded) forward with their real HTTP status. Returning 200 for streaming errors had broken OpenAI-compatible clients.

The swap lifecycle

Diagram: circular flow of four boxes labelled IDLE, SWAP, LOAD, SERVE connected by arrows
Slot lifecycle: idle slots swap on demand. VRAM must drain below ~1 GiB before the next model loads.

The registry

Every field the orchestrator understands:

FieldMeaning
gguf / mmprojweights path; vision projector path (forced to CPU via --mmproj-device none)
ctx_size--ctx-size — everything here runs at 200,000 except the flagship at 262,144
gpu_layers--n-gpu-layers; 99+ = full offload
flash_attention--flash-attn on
cache_type_k/_vKV quantization — the 200K-context enablers
ubatch/batchbatching; big batches = fast prefill
temperature/top_p/top_kserver-side sampling defaults
reasoning/reasoning_format/reasoning_budgetthinking extraction (deepseek format = reasoning_content) + budget cap
chat_template_kwargse.g. {“enable_thinking”:true}
fit_gpuwhich GPU slots the model fits on
familydefaults like --n-cpu-moe 0 for MoE families
use_mtp/mtp_n_maxMTP speculative decoding (--spec-type draft-mtp)
wide_slot/split_mode/tensor_splitdual-GPU models
backendnon-default engine — e.g. strata
attachment/tool_call/output_limitclient-facing capability metadata

A trimmed real entry, so you can pattern-match one for your own model:

{
  "gguf": "/mnt/data/llama-models/glm-4.7-flash/model.gguf",
  "ctx_size": 200000,
  "gpu_layers": 99,
  "flash_attention": true,
  "cache_type_k": "q4_0",
  "cache_type_v": "q4_0",
  "ubatch": 256,
  "batch": 2048,
  "temperature": 1.0,
  "top_p": 0.95,
  "reasoning": true,
  "reasoning_format": "deepseek",
  "chat_template_kwargs": "{"enable_thinking":true}",
  "fit_gpu": [
    0,
    1
  ],
  "family": "glm",
  "reasoning_budget": 4096
}

Memory safety on a 128 GB host

The service cgroup carries a hard MemoryMax=110G and LimitMEMLOCK=infinity. The reason for the cap: two Strata instances once livelocked the host, cgroup max events 1,444×, oom_kill: 0, journald stopped writing, because the inference engine had allocated a private pinned huge-page arena (~47 GiB) per instance, leaving nothing reclaimable. No process was ever killed. The machine froze. The fix is a shared arena flag (--shared-expert-arena /dev/shm/…) so all instances map one tmpfs copy. Lesson for any RAM-heavy MoE setup: measure pinned/locked memory per process (smaps_rollup), not just totals.

Running it

curl -s http://127.0.0.1:8010/health            # slot state, active requests
curl -s http://127.0.0.1:8010/v1/models         # every installed model
curl -X POST http://127.0.0.1:8010/admin/slot/1/stop   # free GPU 1 (image-gen jobs, maintenance)
curl -X POST http://127.0.0.1:8010/admin/slot/1/start  # bring it back with its boot model

The admin endpoints make single-GPU image generation and LLM serving coexist: stop slot 1, run the diffusion job on GPU 1, restart the slot. Logs are per-slot (slot{0,1}-<model>.log) plus an orchestrator log, and a thermal watcher wraps every benchmark, both 3090s software-throttle around 72–76 °C, which is normal and affects all models equally.

Benchmarking discipline

All orchestrator numbers in this set come from the same like-for-like method unless noted: identical short prompt, max_tokens=512, temperature=0.7, two runs per model, median reported, models warmed first so load/swap time is excluded, and re-verified with server-reported timings, every model within a few percent, GPU-thermal variation accounted for). Direct runs use llama-cli at 8192 ctx, 256 generated tokens, q4_0 KV, flash-attn on. Both GPUs hit software-thermal/power-cap throttling at 72–76 °C under bench load. This affects all models similarly. Short-prompt prefill numbers are overhead-dominated and comparative only.

Upgrades move real numbers: the llama.cpp b11480→v0.7.0 jump alone changed generation throughput between −5% and +21% per model (six models improved 10–21%). Never quote a tok/s figure without its build, context length and method.

Limits

  • One model per slot: swapping costs ~20–40 s for a llama.cpp model still warm in the 128 GB page cache (measured: gemma4 26 GB → 22 s, GLM-4.7 → 34 s), and ~75–80 s for the Strata flagship, which re-bakes its expert arena. The routing rules exist to make swaps rare, not free.
  • Queue latency is real under contention, the 300 s ceiling turns overload into a clean 503, not a hang.
  • Short-prompt prefill is overhead-dominated. Judge ingestion on long prompts.
  • This is a LAN service: no auth, no multi-tenant isolation. Public exposure would need a completely different shape (proxy + caps), and that is a separate decision.

The engine underneath is llama.cpp (v0.7.0, CUDA, sm_86). The flagship slot uses Strata Terminal. The eleven models and their numbers: Local AI.

The code is open source: ByteCreation/orchestrator. The FastAPI service, a worked registry, systemd units and a recovery script. Every path is env-configurable. The prerequisites are two GPUs and a llama.cpp or Strata binary.

Leave a Reply

Your email address will not be published. Required fields are marked *