
When does self-hosting an LLM beat an API? A break-even worksheet
Compare monthly API and GPU costs with editable inputs, three worked scenarios, and a capacity check that catches false savings.
FIELD NOTES
Memory, latency, and the practical work of serving models.

Compare monthly API and GPU costs with editable inputs, three worked scenarios, and a capacity check that catches false savings.

A three-model binary fixture distinguishes averaging probabilities from averaging log-odds, with a threshold reversal and an odds-based identity check.

An argmax returns column positions, not class IDs. Decode with the fitted vocabulary and locate a requested class before selecting its probability.

A dropped baseline and an unseen category can share an all-zero encoding. Test that collision before relying on inverse transforms or model inputs.

The same five latency samples yield p95 values of 88 ms and 100 ms under two NumPy methods. Keep the estimator and probability scale in the report.

A cached text-only call can survive a model change. Pass an immutable revision identity into the cached computation and test both reuse and revision separation.

Subtract each row maximum before exponentiating logits, keep the reduction dimensions, and test both probability sums and invalid inputs.

A narrowing cast does not implement saturation. Make the rounding, scale and clipping interval explicit in a small symmetric quantization check.

Python evaluates a fallback call before dict.get chooses a value. Use an explicit miss branch to avoid unnecessary computation and retain false-valued results.

A correct matrix shape cannot detect swapped feature meanings. Pack named records using a fixed schema and reject mismatched fields before scoring.

A raw dot product can favor a longer vector over a better directional match. Reproduce the difference and make the zero-vector policy explicit.

NumPy searchsorted can turn an unseen label into a plausible but incorrect category ID. Validate membership against the fixed vocabulary before encoding.

Calculate the dense cache payload from layers, KV heads, token count and dtype, and see why the answer is not a GPU-fit guarantee.