- vllm.service.j2: branch on role==embedding for --runner pooling --convert embed, --no-enable-prefix-caching, per-model trust_remote_code toggle (needed for nomic-embed-text-v1.5's custom NomicBertModel code), and enforce_eager toggle (needed to avoid CUDA graph capture OOM when co-resident with another vLLM process on this 24GB card). - tasks/verify.yml: split completions vs embedding smoke tests -- embedding-mode instances don't serve /v1/completions. Assert a non-empty embedding vector, not just HTTP 200. - host_vars/astro-orbiter: enable nomic-embed-text-v1.5 (port 8020), lower primary model's gpu_memory_utilization 0.95->0.90 + add enforce_eager after finding 0.95 crash-looped 6-7x before stabilizing with co-resident nomic-embed (real fix, confirmed via NRestarts=0 after clean stop/start, not luck). - Hindsight (values.yaml + externalsecret.yaml): cut LLM + embeddings over to vLLM (:8000, :8020), wire the previously-unset HINDSIGHT_API_EMBEDDINGS_* env vars for the first time, and swap the API key secret source from the Nous fallback item to vllm/api-key (vLLM enforces real auth, llama-swap did not). - README: document the embedding-mode branch, VRAM findings, and a genuine architecture gap -- vLLM's one-model-per-process design cannot replace llama-swap's 5-model LRU roster on this 24GB card, so 21 Hermes profiles' aux-model consumers (Qwen3-8B-no_think, Phi-3.5-mini, Meta-Llama-3.1-8B, Qwen2.5-Coder-14B) and OpenViking's VLM stay on llama-swap. Full teardown (t_6dff1ecc) needs a human decision on the aux-model strategy before it can proceed.
deploy-vllm
Idempotent Ansible role that deploys a vLLM OpenAI-compatible inference server. Written for astro-orbiter (RTX 3090, 24GB VRAM, 64GB RAM, Ubuntu 24.04) and designed for reuse on the planned Mac Mini M4 host later this week (see "Portability" below).
Supersedes the manual, pre-role state left behind by earlier vLLM
experiments (/home/jarvis/vllm-env, bitsandbytes, gemma-2-27b — see
homelab-llm-inference/homelab-llm-serving skills for that history). This
role uses a fresh venv (vllm_venv_path, default ~/vllm-serve-env) and
AWQ pre-quantized models — no bitsandbytes, no on-the-fly quantization,
no repeat of the OOM incident from the earlier Gemma-2-27B attempt.
Phases
| Phase | File | What it does |
|---|---|---|
| 1 | tasks/dependencies.yml |
System Python 3.10+, dedicated venv, pip install vllm>=0.5.0, verifies nvidia-smi and torch.cuda.is_available() |
| 2 | tasks/models.yml |
Downloads each enabled: true model in vllm_models via hf download (huggingface_hub CLI) into ~/.vllm-cache, verifies the snapshot landed and reports on-disk size |
| 3 | tasks/api-key.yml |
Reads the API key from 1Password (op://mk-labs/vllm/api-key) on the controller, writes it to /etc/vllm/api-key.env (root:root, 0600) on the target |
| 4 | tasks/systemd.yml |
Renders and installs one systemd unit per enabled model (vllm.service for the role: primary model, vllm-<id>.service for others) |
| 5 | tasks/verify.yml |
Only runs when vllm_service_state=started. Waits for /health (up to 5 min — torch.compile warmup), checks /v1/models, runs a live completion, scans journalctl for errors |
Run all phases: ansible-playbook -i inventory.yml playbooks/day1_deploy_vllm.yml --limit astro-orbiter
Run one phase: --tags vllm-dependencies / vllm-models / vllm-api-key / vllm-systemd / vllm-verify
Deliberate staging-first default
vllm_service_state defaults to stopped. A default run stages
everything (venv, model weights, API key file, systemd unit) but does
not start the service or touch production traffic. This matches the
astro-orbiter cutover plan: llama-swap is live production serving (Qwen3.8-27B
- nomic-embed for Hindsight) — vLLM must be deployed and validated on a side port/inactive unit before anything is cut over.
To start and validate:
ansible-playbook -i inventory.yml playbooks/day1_deploy_vllm.yml \
--limit astro-orbiter --extra-vars "vllm_service_state=started"
This starts the systemd unit(s), enables them, and runs Phase 5 verification
(health, /v1/models, live completion, clean journalctl).
Cutover of consumers (Hermes profiles, Hindsight embedding config, any
hardcoded :8001/:5805 references) to the new :8000 vLLM endpoint is a
separate, explicit step outside this role — do this only after Phase 5
passes cleanly. Do not tear down llama-swap until consumers are confirmed
working end-to-end against vLLM.
Model roster (vllm_models in defaults/main.yml)
vLLM 0.5.x-0.28.x serves one model per process — multi-model = multiple
systemd units on distinct ports, not a single multiplexed server (unlike
llama-swap's matrix DSL). Today's phase enables only the primary model;
flip enabled: true on the others as VRAM allows (see "Phased Strategy"):
| id | hf_repo | role | port | quant | enabled |
|---|---|---|---|---|---|
| Qwen2.5-32B-Instruct-AWQ | Qwen/Qwen2.5-32B-Instruct-AWQ | primary | 8000 | awq | true |
| Qwen3-8B-AWQ | Qwen/Qwen3-8B-AWQ | aux | 8010 | awq | false |
| nomic-embed-text-v1.5 | nomic-ai/nomic-embed-text-v1.5 | embedding | 8020 | none | false |
Note on the original spec's model choices: the task body named
Qwen/Qwen2.5-32B-Instruct and Qwen/Qwen3-8B-Instruct (bf16, unquantized).
vLLM does not do on-the-fly quantization safely on this host (bitsandbytes
OOM history — see homelab-llm-inference skill Pitfalls) and unquantized
bf16 32B does not fit a 24GB card at all (~65GB). This role instead deploys
the official Qwen AWQ pre-quantized variants
(Qwen/Qwen2.5-32B-Instruct-AWQ, Qwen/Qwen3-8B-AWQ), which vLLM natively
supports (--quantization awq) and which fit the VRAM budget:
- Qwen2.5-32B-Instruct-AWQ: ~19.3GB on disk, fits with ~5GB headroom at 24GB
- Qwen3-8B-AWQ: ~6GB VRAM per llm-explorer
- nomic-embed-text-v1.5: ~300MB, vLLM serves it via
--convert embedpooling (see vLLM embedding docs) — not yet wired into this role's systemd template; the embedding model needs--task embed/--convert embedflags that differ from the completion-serving template. Flagged as a follow-up beforeenabled: trueis flipped on it (see Known Gaps below).
Known Gaps / Follow-ups
- Quarterly API key rotation is documented (
/etc/vllm/API_KEY_ROTATION.mdon the target, rendered bytasks/api-key.yml) but not automated — no cron job exists to force rotation on a schedule. Consider a follow-up cron task if Nick Fury wants this enforced rather than just documented. vllm_service_enableddefaults tofalsedeliberately — see "Deliberate staging-first default" above. Flip together with the cutover step, not before.- vLLM cannot replace llama-swap's full model roster on this card (t_e6facb19, 2026-08-31).
This role only wires two of llama-swap's five served models: the primary
completions model (Qwen2.5-32B-Instruct-AWQ, replacing Qwen3.8-27B) and
the embedding model (nomic-embed-text-v1.5). llama-swap ALSO serves
Qwen3-8B-Q4_K_M(-no_think), Phi-3.5-mini-instruct-Q8_0,
Meta-Llama-3.1-8B-Instruct-Q4_K_M, and Qwen2.5-Coder-14B-Instruct-Q4_K_M —
21 Hermes agent profiles'
custom_providersreference these model IDs for aux tasks (skills_hub, approval, mcp, title_generation, profile_describer, compression). vLLM 0.28 serves one model per process; running 5-6 separate vLLM processes concurrently does not fit a 24GB card (each process reserves its own CUDA context + weights + KV cache, unlike llama-swap's matrix DSL which time-shares one GPU across LRU-evicted processes). Full llama-swap teardown (t_6dff1ecc) cannot proceed until either: (a) the aux-model consumers are migrated to a different backend (Anthropic, or a smaller local llama.cpp router kept alongside vLLM), or (b) vLLM gains a comparable multi-model time-sharing mode. This is a genuine architecture gap, not a missing role feature — flagging for a human decision on the aux-model strategy before teardown can be unconditionally safe.
Embedding-mode support (t_e6facb19, 2026-08-31)
vllm.service.j2 now branches on role: embedding entries in vllm_models:
adds --runner pooling --convert embed (vLLM's embedding-serving flags —
see https://docs.vllm.ai/en/latest/models/pooling_models/embed/) and
--no-enable-prefix-caching (prefix caching is a completions-only
optimization; irrelevant and safely disabled for pooling). An additional
per-model trust_remote_code: true toggle renders --trust-remote-code
when set — required for nomic-ai/nomic-embed-text-v1.5, which ships
custom NomicBertModel modeling code on its HF repo.
Verification does NOT run /v1/completions against embedding-mode
instances (they don't serve that endpoint — a completions request 400s
immediately). tasks/verify.yml splits vllm_enabled_models by role and
runs the appropriate smoke test per group: completions models get the
/v1/completions "capital of France" test; embedding models get a real
/v1/embeddings POST with an ansible.builtin.assert on a non-empty
data[0].embedding array (not just HTTP 200 — an empty/malformed vector
would still 200).
Critical VRAM finding: co-resident completions + embedding vLLM processes
need MORE headroom than either alone, and CUDA graph capture is the failure
mode, not KV cache sizing. Enabling nomic-embed-text-v1.5 alongside the
primary Qwen2.5-32B model at the role-default gpu_memory_utilization: 0.95
crash-looped repeatedly:
- First failure:
torch.OutOfMemoryErrorduringcapture_model()(CUDA graph capture) — KV cache sizing itself succeeded (14,720 tokens allocated), but graph capture needed ~20MiB more than the 0.95 budget had left once nomic's embedding process (814MiB actual, not the nominal ~300MB estimate in the model roster table) claimed its share. - Fix attempt 1: added a per-model
enforce_eager: truetemplate branch (--enforce-eagerskips CUDA graph capture entirely) — this stopped the graph-capture OOM but the combined processes still landed at only ~847MiB genuinely free out of 24,576MiB, and both services crash-looped 6-7 times during warmup before finally stabilizing (each attempt leaves transient VRAM that the next attempt fights over, extending time-to-stable well past a single health-check retry window). - Fix attempt 2 (final, verified stable): lowered the primary model's
gpu_memory_utilizationfrom 0.95 to 0.90 (host_vars override) in addition toenforce_eager: true. Result: clean single-attempt start for both services,NRestarts=0, ~2GB genuinely free (22,577MiB used / 24,576MiB total). Confirmed viasystemctl show <unit> -p NRestartsafter a full stop/start cycle — 0.95 was NOT a fluke of Restart=always masking the underlying fragility; 0.90 is a real, reproducible fix. - Takeaway for future multi-process vLLM VRAM budgeting on this host:
do not just check "does it eventually come up" — check
NRestartsand free VRAM headroom after a clean stop/start. A model that "works" after 6 crash-loop retries is not production-stable; the retries themselves are evidence the utilization ceiling is too tight for the actual (not nominal) footprint of co-resident processes.
Consumer cutover status (t_e6facb19, 2026-08-31)
Cut over (validated end-to-end):
- Hindsight (
cluster/applications/hindsight/values.yaml+externalsecret.yaml):HINDSIGHT_API_LLM_BASE_URL→ vLLM:8000(Qwen2.5-32B-Instruct-AWQ), plus newly-wiredHINDSIGHT_API_EMBEDDINGS_*env vars pointing at vLLM:8020(nomic-embed-text-v1.5). Both endpoints require vLLM's real API key (unlike llama-swap, which accepted any/no key) — ExternalSecret now readsop://mk-labs/vllm/api-key(item "vllm") instead of the prior Nous fallback item, and reuses the same key value forHINDSIGHT_API_EMBEDDINGS_OPENAI_API_KEY(both vLLM endpoints share one key file pertasks/api-key.yml).
NOT cut over — genuine scope gap requiring a human decision, see
"Known Gaps" above: the 21 Hermes agent profiles' aux-model
custom_providers entries (Qwen3-8B-no_think, Phi-3.5-mini, Meta-Llama-3.1-8B,
Qwen2.5-Coder-14B) still point at llama-swap :8001 — vLLM has no
equivalent multi-model serving mode on this 24GB card. llama-swap MUST stay
up to serve these until that gap is resolved. This is why the teardown task
(t_6dff1ecc) remains blocked even after this task's completion — see the
comment posted there.
- OpenViking (
cluster/platform/openviking/values.yaml): still points at llama-swap:8001(Meta-Llama-3.1-8B-Instruct-Q4_K_MVLM + nomic-embed for dense embeddings). Left unchanged — its VLM model has no vLLM equivalent staged, and migrating only its embedding path while leaving its VLM on llama-swap would still require llama-swap up, providing zero teardown benefit. Flagged, not touched, per the same aux-model gap above.
Validation Log (2026-08-31, t_ca1af9fb)
Full Phase 1-5 run executed against astro-orbiter in a brief shadow-validation
window (llama-swap stopped ~5 min, per the homelab-llm-inference skill's
documented shadow-validation pattern — production traffic could not be
tested concurrently with vLLM's VRAM footprint on this 24GB card).
Two real bugs found and fixed during first-start validation (not present in the original spec, discovered only by actually starting the service):
ninjanot on systemd's PATH. vLLM's torch.compile path shells out to the bareninjacommand.pip install vllminstallsninja(and its console-script entrypoint) into the venv'sbin/, but systemd's minimal default PATH doesn't include that directory —FileNotFoundError: 'ninja'only reproduces under systemd, not interactive SSH testing. Fixed by settingEnvironment="PATH=<venv>/bin:...standard dirs..."in the unit template.- FlashInfer sampler JIT fails to compile on RTX 3090 (SM86).
flashinfer/data/csrc/sampling.cuuses a cub template API (BlockAdjacentDifference::FlagHeads) not present in this flashinfer/CUDA-toolkit combination — 100 compile errors, confirmed as a known upstream issue class (vLLM GH #23023, #44305: FlashInfer sampler JIT breaking on various SM targets). Fixed withEnvironment="VLLM_USE_FLASHINFER_SAMPLER=0", falling back to vLLM's native PyTorch sampler (fully supported, negligible perf difference at single-request serving volume).
Also corrected vllm_gpu_memory_utilization from 0.90 to 0.95 — at 0.90 the
KV cache allocation failed (2.0 GiB KV cache needed, 1.3 GiB available)
even with the full 24GB card free, because 32B AWQ weights alone consume
~18.4GB, leaving too little headroom at a 90% cap.
Idempotency bug also found and fixed: upgrading setuptools to "latest"
in Phase 1 fought with vLLM's own setuptools<81.0.0 pin, causing a
install/downgrade flip-flop (changed: true) on every single run. Fixed by
removing setuptools from the explicit-upgrade list and letting vLLM's own
pip install resolve it.
Final validated result, once these fixes were applied:
systemctl status vllm.service→ active, clean journalctl (no error/traceback lines) after the successful startcurl /health→ HTTP 200curl /v1/models→ returnsQwen2.5-32B-Instruct-AWQcurl /v1/completions→ live completion returned correct output ("The capital of France is" → " Paris. Correct! The capital of France")- Second and third full-role runs (
vllm_service_statedefault,stopped) →changed=0both times — confirmed idempotent - Production restored:
llama-swap.serviceactive,/health200,/v1/embeddingsagainstnomic-embed-text-v1.5returns a valid vector — Hindsight retain path confirmed still working after the shadow window - Post-restore VRAM: 486 MiB used / 24,576 MiB total (normal quiescent state)
Testing this role (idempotency)
Second-run test (staging phases only, safe to run repeatedly):
ansible-playbook -i inventory.yml playbooks/day1_deploy_vllm.yml \
--limit astro-orbiter --tags vllm-dependencies,vllm-models,vllm-api-key,vllm-systemd
# Run it again immediately — expect changed=0 (or only handler-driven
# restarts if vllm_service_state=started and the API key file rotated)
Confirmed 2026-08-31 (t_ca1af9fb): Phase 1 (dependencies) ran once with
changed=3 (venv create, pip upgrade, vllm install); a second run reported
changed=0 for those three tasks — venv creates: guard and pip module's
own idempotency both held.
Portability — Mac Mini M4 (planned, end of week)
This role's host-specific assumptions live in defaults/main.yml (all
overridable via host_vars/<host>/vars.yml) plus one hard assumption baked
into tasks/dependencies.yml: an NVIDIA GPU (nvidia-smi check, CUDA
wheels). Apple Silicon has no CUDA — vLLM's Metal/MPS backend support is
immature as of this writing. Before reusing this role for the Mac Mini M4:
- Fork
tasks/dependencies.yml's GPU-check + CUDA-wheel-install logic into a platform-conditional block (when: ansible_facts.system == 'Darwin'branch installing the CPU/MPS vLLM wheel, or MLX-based serving instead — needs a decision before that work starts, not assumed here). vllm_venv_owner,vllm_serve_port,vllm_modelsare already host_vars- driven — no changes needed there.- systemd unit templates assume a Linux init system — macOS needs a
launchd plist instead of
vllm.service.j2.
This is flagged as a distinct follow-up task, not solved in this role — scope for this deployment was astro-orbiter only, per the task body's "Phased Strategy: ... End of week: Mac Mini M4 variant" (a separate future pass, not blocking this completion).
Files
roles/deploy-vllm/
├── defaults/main.yml # all tunables — host overrides go in host_vars
├── handlers/main.yml # reload systemd / restart vllm services
├── meta/main.yml
├── tasks/
│ ├── main.yml # phase orchestrator
│ ├── dependencies.yml # Phase 1
│ ├── models.yml # Phase 2
│ ├── api-key.yml # Phase 3
│ ├── systemd.yml # Phase 4
│ └── verify.yml # Phase 5
├── templates/
│ ├── vllm.service.j2 # one instance per enabled model
│ └── vllm-workspace.sh.j2 # debugging helper deployed to the target
└── README.md # this file