Strix Halo LLM Router — Local Inference OS

A local inference operating system for unified-memory APUs. It runs 5+ large models (26B–35B params) simultaneously on a single consumer box with no cloud, no NVIDIA tax, and no datacenter complexity.

The router owns mechanism — slots, memory, context profiles, scheduling, batching, caching. The agents own policy — what to do, in what order, with what handoffs. They communicate via OpenAI-compatible chat completions plus a small set of hint extensions.

This is the OS kernel/userspace split, applied to local inference.


What this system actually is (no fluff)

This is systems integration engineering at the edge of consumer hardware, not fundamental research. None of the individual algorithms are novel:

  • Intent classification is keyword matching, not ML research.
  • Context profiling is heuristic estimation with Bayesian smoothing.
  • Continuous batching is llama.cpp’s existing -np feature exposed through a semaphore.
  • Prefix caching is a HashMap lookup, not SGLang’s radix tree.
  • Predictive preloading is a first-order Markov chain.

The novelty, such as it is, lies in the combination and the hardware target:

What exists elsewhere What does NOT exist
vLLM: continuous batching, prefix caching On a single 128GB consumer APU with unified memory
Ollama: simple local inference 5+ 26B–35B models resident simultaneously
LiteLLM: model routing Intent classification + dynamic context sizing + predictive preloading + pipeline orchestration in one binary
SGLang: radix attention On a Strix Halo with Mesa Vulkan drivers

The breakthrough is not an algorithm. It is that the whole stack runs on a Strix Halo without falling over.

Guiding principle: tokens per byte

The APU has a fixed memory bandwidth budget (~273 GB/s on Strix Halo). You cannot increase it. The only lever is how many useful tokens you extract per byte transferred.

time_per_token ≈ model_size_bytes / effective_bandwidth

You cannot change effective_bandwidth (silicon). You can change model_size_bytes per useful token. This is the frame that drives all optimization decisions:

  1. Batching — read weights once, apply to N sequences. Already validated: +110% effective throughput at 4× concurrency.
  2. Prefix caching — stop recomputing shared document/system-prompt prefixes.
  3. Speculative decoding — draft model verifies N tokens in one forward pass. Pending.
  4. KV quantization — already applied (Fast q4_0, Reason q8_0).
  5. Distillation / MoE conversion — model-level bandwidth reduction. Future research.

Deprecated frames: “avoid concurrent GPU usage,” “CPU offload to eliminate contention,” “temporal multiplexing to serialize access.” All of these treat bandwidth as an enemy to avoid rather than a budget to optimize.


What lives in the Router

Slot lifecycle — spawn, evict, OOM-aware respawn, idle timeout. No agent ever decides to spawn or kill a llama-server process. Why: spawning costs seconds and locks memory; one component must own that decision globally.

Context profile selection (C′ + C″ + C‴) — token estimation, output prediction, history blending. Agents send raw prompts; the router decides whether they get Chat/Standard/Extended/Maximal. Why: agents will systematically over-request context “to be safe” and starve other workloads.

Intent classification — keyword-only classifier (98.4% curated). Why: it’s the cheapest possible routing signal and lives at the only point that sees all traffic. Agents can override with explicit X-Gateway-Intent headers.

Per-slot resource policy — HashMap<Slot, Arc<Semaphore>> keyed by slot, permits = config.parallel for LlamaCpp slots. Different slots run concurrently; same slot batches up to parallel requests via llama-server’s continuous batching. Why: on a memory-bound APU, reading weights once and applying to N hidden states is the highest-ROI throughput win.

Request collation — when queue depth > 1, hold requests for a 20 ms window before releasing to the semaphore. Realtime priority bypasses entirely. Why: staggered arrivals (5–15 ms apart) otherwise miss the batching window.

Memory ceiling enforcement — 112GB ceiling, free-RAM floor. Why: the agents have no visibility into total system memory; the router must refuse spawns that would OOM.

Priority lanes — X-Gateway-Priority: interactive | batch | realtime. Interactive requests skip batch_only slots and get shorter queue timeouts (5s vs 30s). Realtime bypasses the collation window. Why: foreground chat latency degrading because a background research agent is hogging Reason is the single most common failure mode.

Automatic prefix cache — gateway tokenizes the messages array per tokenizer family (Gemma, Qwen) and maintains a prefix cache. Routes to the slot that already holds the longest matching prefix in its KV cache. Evicted on slot standby. LRU eviction at capacity. Why: multi-turn conversations and document analysis recompute the same prefix tokens repeatedly; this stops that waste without agents managing slot affinity.

Manual KV cache reuse — prompt_cache_id as an optional body parameter for agent-managed cache affinity. Why: some workloads (chunked document processing) benefit from explicit cache control.

Backpressure / queueing — requests wait on per-slot semaphores with timeout. Returns 503 on timeout. Why: llama-server’s internal queue is opaque; you can’t prioritize within it.

Fallback chain — explicit → classifier → loaded-with-overlap → cloud (unwired). Why: agents shouldn’t know what’s loaded; if Reason is OOM-evicted, the router silently degrades to Fast.

Metrics & observability — Prometheus, dashboard. Why: observability is a property of the boundary.

Streaming — SSE pass-through, owned permit per stream. Why: streams are inference state; router owns inference state.

What the router explicitly does NOT do:

  • Decide which agents exist, when to spawn them, or how to coordinate them.
  • Hold conversation history. (Each request is stateless from the router’s view.)
  • Manage tool/function definitions.
  • Decide what gets stored where (Supabase vs. LanceDB).
  • Synthesize results across multiple inference calls.
  • Run ML research. (Keyword classifier, heuristic profiling, Markov preloading — all good enough, not cutting edge.)

What lives in the Agents

Topology — which agents exist for a given task, who hands off to whom, when to fan out, when to converge. Why: topology is the actual problem; the router is just the engine.

Tool / function definitions — each agent declares its own tools. Tool execution happens in the agent’s process. The router only sees the model’s tool-call output as text. Why: tools have side effects; side effects must be locally owned.

Memory layers — three tiers:

  • Working memory (chunking agent’s temporal store) — LanceDB, embedded, in-process.
  • Durable knowledge (research outputs) — Supabase + pgvector.
  • Conversation state (chat agent’s session) — wherever the chat agent keeps it.

Why: memory is policy. Different agents have different retention, freshness, and access patterns.

Prompts, personas, system messages — agent-owned. The router never injects system prompts. Why: routing is content-agnostic.

Conversation history & multi-turn state — agent-owned. Each request to the gateway is self-contained. Why: this makes the router stateless and horizontally trivial.

Result synthesis — when parallel agents return, the agent layer reconciles. The router never sees “result A vs result B.”

Priority assignment — the agent stamps X-Gateway-Priority based on its own role. The router enforces; the agent classifies. Why: only the agent knows whether it’s user-facing or background.

What the agents explicitly do NOT do:

  • Pick which slot to use, except as a hint (model: "Reason").
  • Spawn or kill llama-server processes.
  • Manage parallel, ctx_size, or any llama.cpp flag.
  • Hold a global semaphore or implement their own request queue across agents.
  • Read slots.toml. Ever.

The contract between them

Tiny. Three things:

  1. OpenAI-compatible chat completions — /v1/chat/completions, streaming and non-streaming.

  2. Hint headers — small, optional, ignorable:

    • X-Gateway-Priority: interactive | batch | realtime
    • X-Gateway-Intent: summarize | list | explain | write | code | analyze | chat | trivial
    • X-Gateway-Lease: foreground
  3. Response metadata — the router tells the agent what actually happened: which slot, which profile, fallback or not, queue wait.

That’s it. No bidirectional state. No agent registration. The router has no idea what agents exist; agents have no idea what slots.toml looks like.


Completed experiments

These validated the core architecture. Their conclusions are now part of the system.

  1. Per-slot GPU semaphores — Replaced global semaphore. Same slot batches; different slots run concurrently. Continuous batching validated at +110% throughput (4× concurrency).
  2. Cache thrashing diagnosis — Asymmetric degradation (Fast -68%, Reason -12%) with 96% DRAM traffic collapse at 100% GPU utilization confirmed L2 cache thrashing, not bandwidth saturation. Reframed optimization strategy to tokens-per-byte.
  3. Priority lanes — interactive | batch | realtime implemented. Interactive skips batch_only; realtime bypasses collation.
  4. KV cache reuse — --cache-reuse 256 + prompt_cache_id routing + automatic prefix cache.
  5. Request collation — 20 ms window, queue-depth-gated. Validated throughput scaling.

Open research (do when needed, not before):

  • Speculative decoding acceptance-rate measurement
  • LanceDB integration spike for agent working memory
  • Cold-start tax measurement (spawn latency end-to-end)
  • Model distillation or sparse upcycling for permanent bandwidth reduction

The one-page summary

The router is your kernel. It owns slots, memory, context profiles, scheduling, batching, caching, and resource policy. It is stateless from the agent’s perspective and never reasons about tasks.

The agents are your processes. They own topology, conversations, tools, memory, personas, and result synthesis. They never touch llama.cpp directly.

The contract is OpenAI-compatible HTTP plus three hint headers. Nothing else crosses the boundary.

The target is not datacenter scale. It is not edge-tiny inference. It is desktop AI at model scale — 5+ large models on one consumer APU, no cloud required.

2 Likes

Hi, treating the system like a computer’s brain (the Router) to manage the memory and tasks (the Agents) is exactly how AMD chips should be used :smiley: . Most people see the memory limit as a wall, but you are treating it as a budget to spend wisely. Running five large models at once on a home desktop without an expensive NVIDIA card is amazing. I totally want to see such projects more and I wish you the best of luck. Thanks for sharing

1 Like

Sounds awesome, and just what I was looking to do/putting together myself! The things that I am planning on working on personally I PURELY want ALL (or nearly all) of the LLM’s and agents LOCAL and fully contained in my HomeLAN. Is this something you have active up on github or purely putting together as you go?

Its been a lot of work, repo is currently private until i have it clean. It would be amazing to work on this with someone as I’m flying by the seat of my pants. I haven’t really dug into how system agnostic it is at the moment, but the models themselves are and theoretically the slots themselves can be added or removed.

1 Like

I have found another maintenance flaw that I’m now working on…automated model family architecture. I now have to automate the process of model family → specific model → metadata ..This script pulls from huggingface so that no specific characteristics of each model are hardcoded across the router. Examples include context window, thinking, RoPE, flash attn, quant, head dim, kv head, batch, etc.. (this is getting complex)

1 Like

Update since this post. The high-level frame (router-as-kernel, agents-as-userspace, OpenAI-compatible contract, tokens-per-byte as the optimization frame) all held up. What changed is underneath.

The Vulkan-context constraint became architecture. The original treated GPU concurrency as a scheduling problem. It’s actually a driver problem: each Vulkan context init on Strix Halo (Mesa/RADV/amdgpu) creates ~3,400 persistent kworker threads. 3+ contexts running concurrent compute wake them simultaneously, driving load average above 3,000 and destabilizing the system. The fix isn’t fewer models — it’s one Vulkan context with multiple models in it. So the multi-llama-server design is gone, replaced by a single companion process linked against libllama.so, communicating with the gateway via Unix socket. Six of seven generative slots now live in the companion; Vision is the holdout (blocked on CLIP/mmproj integration).

Process count is now a numbered principle. Target is four: gateway, companion, two Python audio. Process boundaries exist for crash isolation, security, or distinct runtime stacks — never for architectural convenience.

Same-model weight sharing. A consequence of consolidation: when two slots use the same base model (Code and Tool both run Qwen 3.6-35B-A3B), they share weights via ref-counting and concurrent decode batches into a single llama_decode. Measured: 199% efficiency vs sequential, ~16 GB saved. This kind of win only becomes available once you’re in one process.

Honest result on concurrent multi-model. Original framing implied throughput gains from running multiple models simultaneously. Real number: Fast + Reason + Tiny concurrent is 1.03× sequential. The APU is bandwidth-bound at 273 GB/s — concurrency buys availability (right model already loaded), not aggregate throughput. Tokens-per-byte predicts this; concurrency was never the lever.

In-process embedder/reranker. Candle (embedding) and ONNX (rerank) moved into the gateway binary, eliminating two more Vulkan contexts. PolarisDB (in-process vector store) handles k-NN and prefix-cache persistence.

Benchmarks that came in: prefix cache 10.5× on full hits, routing accuracy 98.4% curated / 87.7% real-world / 96.7% hold-out, output token prediction MAPE 18% (down from 341% baseline), gateway routing overhead ~1ms (<1%), companion C++ overhead 3–7% vs llama-server baseline.

Known open items: cold-start latency end-to-end is unmeasured (next up), and SSE streaming in the companion is currently simulated word-chunking rather than real per-token emission. Both on the critical path before any external claim about interactive UX.

The architecture compresses now: one Vulkan context, four processes, safe Rust in the kernel, every benchmark validates the constraints

1 Like

Sorry for the slow reply - the original login with AMD Dev/Com was at work and I didn’t have anything saved to look at from another machine over the weekend.

Will read through your other (newer posts) - but yea I get where you are coming from, definitely a LOT of things to consider and work out. I am just getting started with the AMD stuff and my NVIDIA rigs at work are just as messy if not not worse at times. :smiley:

Coupled with I am dealing with a frustrating “medical issue” it definitely has its challenges! Over the weekend I needed to focus on testing 2 more 3080TI’s that I got recently used from eBay to make sure they were good to go on my other server that I am standing up.

Will keep in touch - but yea, definitely tough going with all of this. It seems like I am able to get one step forward and 2 steps back MOST of the time! LOL!

Yeah on my home rig (Strix Halo) I kept running into conflicting stories about how to setup the hardware. Seems like both have their arguements - but I ended up finally setting the designated VRAM to be the LOWEST possible setting in BIOS and then Ubuntu Server / Drivers will allocate the ram to be used as GPU tasking. Based on that - loading up I had issues with ROCm loading things up with vLLM/Podman - so removed all of that and went with Vulkan and back to ollama and things seem to be running better. I definitely need to do some bencharking though to ensure the tokens being generated are within “normal” spec, definitely seems to be running a bit slow.