Production LLM Infra Guardrails Kit (PDF + 3 Python scripts)
A GPU-hour is not a budget. An index is not the vector column. A pass rate is not a measurement.
Three numbers decide whether an LLM platform survives its second quarter, and all three are arithmetic you can do before the invoice arrives:
• On a $1.736/h H100 decoding 1,800 tokens per second, an output token costs $0.268 per million. A $50 daily cap is 287,000 requests of 2,000 in and 400 out - and a retry loop can spend it by lunchtime.
• Ten million 1,536-dimension vectors with HNSW and m=16 need 69 GB of index plus 63 GB of heap. As halfvec, the same data needs 35 GB and a $336 instance instead of a $1,008 one.
• A 90% pass rate at plus or minus 2 points needs 865 judgements per run, whether you serve 20,000 requests a run or 20 million. The same sample costs $9.72 a month on a small judge and $777.60 on a frontier one.
This kit is those three decisions, worked out, with the tools to run them on your own numbers.
WHAT YOU GET
The guide - 15 pages, 4 figures, 9 tables
• Part I - The spend cap. Why vLLM's four limits are not a budget; how to convert an hourly GPU rate into a price per token; reservation versus post-hoc accounting, and the concurrency race that makes the second one useless; the three failure modes of a request that does not end normally; and what a day of budget actually buys.
• Part II - Index size. The bytes pgvector really stores (vector plus graph, not vector alone); dimension and type limits that fail hours into a build; the maintenance_work_mem trap and the DDL that avoids it; recall as a query-time setting; the instance price at 2M, 10M and 50M rows.
• Part III - Evaluation sampling. Sample size from the tolerance of the decision, not from traffic; the judge-price spread that is 80x larger than the sampling-rate spread; Neyman allocation with a per-stratum floor; sequential gates and the false-alarm tax of a daily fixed test.
THE SCRIPTS - llm-infra-guardrails-kit-v1.0.zip
• vllm_spend_cap.py - a proxy in front of vLLM (or any OpenAI-compatible server). Reserves the worst-case cost of each request against a SQLite ledger, reconciles with the real usage the server returns, and returns 402 with the remaining balance when the period budget is gone. Streaming, embeddings, Prometheus metrics, /budget endpoint, Docker file.
• pgvector_index_sizer.py - index bytes, build memory, recommended RAM and the cheapest instance that holds it, from rows, dimensions, type and m. Emits the CREATE INDEX statement and the postgresql.conf values.
• eval_sampling_budget.py - sample size from a target interval, monthly cost from a judge price, Neyman allocation with a floor, and a simulated sequential test that reports its average and worst-case sample.
• Plus - config.example.json, strata.example.json, ledger_postgres.sql (multi-replica ledger), Dockerfile, docker-compose.example.yml and a README runbook.
Every script runs on the Python standard library and ships with --selftest:
python3 vllm_spend_cap.py --selftest -> all checks passed
python3 pgvector_index_sizer.py --selftest -> all checks passed
python3 eval_sampling_budget.py --selftest -> all checks passed
WHO IT IS FOR
• Teams running vLLM, TGI or SGLang who have no answer to "what stops the bill?"
• Anyone about to build a pgvector index who cannot yet say how big it will be.
• ML and platform engineers asked to prove that an evaluation is statistically meaningful.
• Finance or ops people who have to defend an AI budget line with arithmetic.
WHAT IT IS NOT
Not a vLLM fork, not a billing system, not a benchmark, and not legal or financial advice. The ledger is your cost model, not an invoice: idle GPU time is real money and is not in it.
FILES: 1 PDF (15 pages) + 1 ZIP (3 Python scripts, README, config, Postgres ledger, Docker files).
Edition: First, December 2026. Prices and limits checked 4 December 2026.