Skip to content

Tune LLM API infra, add benchmark/eval scripts, document in docs/AGENTS.md - #4

Open
elimelt wants to merge 1 commit into
mainfrom
llm-api-tuning-and-benchmarks
Open

Tune LLM API infra, add benchmark/eval scripts, document in docs/AGENTS.md#4
elimelt wants to merge 1 commit into
mainfrom
llm-api-tuning-and-benchmarks

Conversation

@elimelt

@elimelt elimelt commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

Infrastructure tuning, benchmarking tooling, and operational docs for the LLM API at llm.elimelt.com (Ollama behind Caddy).

Changes

Caddyfile

  • Rate limit raised 20 → 100 req/min per IP (the notes app was tripping 429s)
  • Internal origins (https://*.elimelt.com, http://localhost:5173) exempted from rate limiting
  • CORS preflight/headers and blocked model-management endpoints restructured into handle blocks

docker-compose.yml (ollama)

  • OLLAMA_ORIGINS=* — Ollama's built-in Origin validation was returning 403; origin policy is enforced by Caddy at the edge instead
  • OLLAMA_NUM_PARALLEL=4 — concurrency benchmarks showed CPU-bound throughput plateaus at ~4
  • OLLAMA_MAX_QUEUE=20 — backpressure instead of unbounded queueing
  • Memory limit 6G → 50G — 26B-class models were OOM-killing the container

New scripts (infra/scripts/)

  • bench_ollama.py — TTFT/decode/prompt benchmark; distinguishes first token (incl. thinking) from first content, and runs thinking-capable models (gemma4, gpt-oss) in both modes
  • bench_ollama_concurrency.py, bench_ollama_prefill.py
  • eval_tts_rewrite.py, eval_tts_prompts.py — quality evals for the notes→TTS rewrite task

Docs

  • docs/AGENTS.md — model lineup rationale, thinking-model gotchas, benchmark results, CORS/rate-limit behavior

Server-side model changes (not in repo, recorded for history)

Pulled gemma4:e4b, gemma4:26b, gpt-oss:20b, qwen2.5-coder:7b; removed gemma3:27b and llama3.2:3b as Pareto-dominated. Final lineup benchmarks (warm, medians of 3):

Model 1st content Decode Role
gemma2:2b 206ms 27.4 t/s speed / TTS-rewrite
gemma4:e4b (think: false) 439ms 15.4 t/s mid quality, fast cold load
gemma4:26b (think: false) 448ms 16.7 t/s best quality-per-second (MoE)
gpt-oss:20b (think: "low") 1.5s 12.8 t/s reasoning / tools (MoE)
qwen2.5-coder:7b 200ms 11.2 t/s code

Verification

  • All models return 200 via https://llm.elimelt.com/v1/chat/completions
  • CORS preflight verified live for localhost:5173 and *.elimelt.com
  • Benchmarks/evals in this PR were the tools used to produce the numbers above

…TS.md

Caddyfile (llm.elimelt.com):
- Raise rate limit 20 -> 100 req/min per IP
- Exempt internal origins (*.elimelt.com, localhost:5173) from rate limiting
- Restructure CORS/preflight and blocked-endpoint handling into handle blocks

docker-compose.yml (ollama):
- OLLAMA_ORIGINS=* (Ollama's own Origin check returned 403; policy is
  enforced by Caddy at the edge instead)
- OLLAMA_NUM_PARALLEL=4 (concurrency benchmarks plateau at ~4 on CPU)
- OLLAMA_MAX_QUEUE=20 for backpressure
- Memory limit 50G (26B models OOM-killed the container at 6G)

infra/scripts:
- bench_ollama.py: TTFT/decode/prompt benchmark; distinguishes first token
  (incl. thinking) from first content, runs thinking models in both modes
- bench_ollama_concurrency.py, bench_ollama_prefill.py
- eval_tts_rewrite.py, eval_tts_prompts.py: quality evals for the
  notes -> TTS rewrite task

docs/AGENTS.md: operational notes (model lineup rationale, thinking-model
gotchas, benchmark results, CORS/rate-limit behavior)

Model lineup changes (server-side, recorded here for history): pulled
gemma4:e4b, gemma4:26b, gpt-oss:20b, qwen2.5-coder:7b; removed gemma3:27b
and llama3.2:3b as Pareto-dominated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant