Local LLM platform for knowledge-transfer documents
Answers questions over knowledge-transfer documents with a quantized local model on CPU-only EKS nodes, and restarts in 6 s with the model cached on the node.
- Role
- Personal project
- Stack
- Amazon EKS
- llama.cpp
- Qwen3-4B
- Karpenter
- KEDA
- Amazon S3
- ONNX
Problem
Knowledge-transfer documents are sensitive, and people need to ask questions about them. I wanted a language model that runs on infrastructure I control instead of a hosted API, and I wanted to learn what that costs in speed and operations.
Constraints
- CPU only. Inference runs on
m7i-flex.largenodes (2 vCPU, 8 GiB) with no GPU. - Load target. The design target is 50–100 concurrent users. This is a target, not a measured number.
- Small corpus so far. I have tested only with small documents, so there is no real corpus size yet.
Approach
The platform runs on EKS, with Karpenter provisioning nodes and KEDA scaling the workloads.
- Generation. llama.cpp serves Qwen3-4B-Instruct-2507 in quantized form (Q4_K_M and Q4_0). The backend runs 4 requests at once, queues 8 more, and returns a 429 after that.
- Retrieval. An embedder service, separate from generation, handles embeddings and reranking. It uses bge-small to embed and bge-reranker-base to rerank, both as int8 ONNX models. Their outputs match the full fp32 models closely: cosine similarity is 0.980 for bge-small and 0.992 for bge-reranker-base. The embedder processes 4.6 chunks per second.
- Model storage. The model lives in S3, not in the container image. It is split into 512 MB and 1 GB shards with a SHA-256 manifest.
Key decisions and trade-offs
I tried splitting prefill from decode, measured it, and dropped it
In llama.cpp, a prefill pod reads the prompt and saves its KV cache through slot save and restore. A kvsync sidecar moves the cache through S3, and a decode pod restores it and generates. The output matched the normal setup. The KV cache was about 78 KB per token, and moving it took 1–5 s.
On the same hardware, the split gave no gain. Two normal, co-located replicas did better:
- Mean time to first token: 29 s co-located, 40 s split.
- Full load test: 178 s co-located, 201 s split.
I kept co-located serving. The split stays behind a DISAGGREGATION_MODE flag and falls back to decode-only if a step fails. I also dropped a vLLM and LMCache option because the model did not fit.
Model shards in S3, with a node cache
Loading the model from S3 shards was meant to fix pod startup time. A first cold start takes about 155 s with every loading method I tried. Warm restarts are where the methods differ:
- Node cache: 6 s.
- Mountpoint S3 driver: 60–71 s.
- Init-container prefetch: 81 s.
The default is the node cache with 1 GB shards.
Q4_0 over Q4_K_M for speed
Generation runs at 3.9 tokens per second with Q4_0 and 3.0 with Q4_K_M, so Q4_0 is about 30% faster. I have not yet measured the effect on answer quality or the memory saved.
Results
- Warm pod restart in 6 s, against a cold start of about 155 s.
- Warm model restarts fell by 93%, from 81 s with init-container prefetch to 6 s with the node cache.
- Prompt tokens fell by 37% at 0.98 key-fact accuracy.
- KEDA scaled inference from 1 to 3 replicas with graceful draining and zero failures across 468 requests.
- Generation at 3.0–3.9 tokens per second on CPU. Reading the prompt runs at 7–19 tokens per second.
- Time to first token is about 30 s for a 571-token prompt and about 7 minutes for 3,000 tokens.
Not measured yet
The evaluation phase has not started. I have not measured answer quality, the effect of reranking on it, or the memory saved by quantization. The concurrency target of 50–100 users is untested, and I have only used small test documents.