llm: extend HostPool fan-out from embeddings to chat/generation #654

Closed
opened 2026-08-18 19:24:20 +00:00 by kert · 2 comments
Owner

llm.pool.HostPool does least-loaded fan-out with health + model checks, but only embed_texts uses it (raw /api/embed). Add the generation analog:

  • generate_texts/chat fan-out over /api/chat (or the OpenAI-compat /v1/chat/completions) with the same least-loaded acquire() discipline, per-host in-flight limit (1-2 — Ollama serializes per-model anyway), timeouts, and tool-call passthrough.
  • Per-host model check before dispatch (a host missing the model is dropped, not errored).
  • Heterogeneous throughput is the point: the pool's least-loaded policy naturally gives the 4090 more work than the 3060 — no static sharding needed.
  • Consumers: prisma screening (companion issue), llm RAG tagging batch runner (#575), #615 post-close comment re-index, #577 golden-set eval.
`llm.pool.HostPool` does least-loaded fan-out with health + model checks, but only `embed_texts` uses it (raw `/api/embed`). Add the generation analog: - `generate_texts`/`chat` fan-out over `/api/chat` (or the OpenAI-compat `/v1/chat/completions`) with the same least-loaded `acquire()` discipline, per-host in-flight limit (1-2 — Ollama serializes per-model anyway), timeouts, and tool-call passthrough. - Per-host model check before dispatch (a host missing the model is dropped, not errored). - Heterogeneous throughput is the point: the pool's least-loaded policy naturally gives the 4090 more work than the 3060 — no static sharding needed. - Consumers: prisma screening (companion issue), llm RAG tagging batch runner (#575), #615 post-close comment re-index, #577 golden-set eval.
kert added this to the P45: GPU Fleet — pooled inference across rack 3060 / rig 4090 / laptop 5070 Ti milestone 2026-08-18 19:24:20 +00:00
kert added the infrallm labels 2026-08-18 19:24:20 +00:00
Author
Owner

Design refinement: the generation fan-out should call /api/chat with options: {num_ctx: 8192} (per-request) instead of requiring the custom qwen2.5:14b-ctx8k Modelfile variant on every host. Then each fleet member needs only a vanilla ollama pull qwen2.5:14b, and context size travels with the request rather than with per-host model state. (The OpenAI-compat /v1 endpoint cannot carry num_ctx, so the pool should speak native /api/chat — it already speaks native /api/embed for the same reason.)

Design refinement: the generation fan-out should call `/api/chat` with `options: {num_ctx: 8192}` (per-request) instead of requiring the custom `qwen2.5:14b-ctx8k` Modelfile variant on every host. Then each fleet member needs only a vanilla `ollama pull qwen2.5:14b`, and context size travels with the request rather than with per-host model state. (The OpenAI-compat `/v1` endpoint cannot carry `num_ctx`, so the pool should speak native `/api/chat` — it already speaks native `/api/embed` for the same reason.)
Author
Owner

Done (2026-09-03, commits 6425557..fafa3d4 on main; spec docs/superpowers/specs/2026-09-03-llm-corpus-recency-links-gpu-design.md).

  • LLM_OLLAMA_HOSTS entries carry declared VRAM (url@24); HostPool.acquire_generation() picks the largest live host that serves the model (re-probed per request, falls back when the rig is down); pick_model() uses qwen2.5:32b on ≥20 GB hosts, else qwen2.5:14b; num_ctx 8192 passed per request.
  • New GET /hosts on the llm service and stack llm hosts CLI show the fleet + the generation pick.
  • Verified live: /hosts → qwen2.5:32b @ 192.168.1.222; a chat through the container loaded 32b on the rig (21.8 GB resident). Embeds still fan out least-loaded across all three GPUs.
Done (2026-09-03, commits 6425557..fafa3d4 on main; spec docs/superpowers/specs/2026-09-03-llm-corpus-recency-links-gpu-design.md). - `LLM_OLLAMA_HOSTS` entries carry declared VRAM (`url@24`); `HostPool.acquire_generation()` picks the largest *live* host that serves the model (re-probed per request, falls back when the rig is down); `pick_model()` uses `qwen2.5:32b` on ≥20 GB hosts, else `qwen2.5:14b`; `num_ctx` 8192 passed per request. - New `GET /hosts` on the llm service and `stack llm hosts` CLI show the fleet + the generation pick. - Verified live: `/hosts` → `qwen2.5:32b @ 192.168.1.222`; a chat through the container loaded 32b on the rig (21.8 GB resident). Embeds still fan out least-loaded across all three GPUs.
kert closed this issue 2026-09-03 14:58:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#654