Prompt
I'm building a low-latency inference service on GPUs
Latest observation
Nov 8, 2026
OpenAI APIWeb search: off
Great—low-latency GPU inference has a few key design choices that matter a lot.
Here’s a practical checklist to optimize for tail latency and throughput:
1) Model/runtime optimization
- Use TensorRT, ONNX Runtime, vLLM, or Triton Inference Server depending on model type.
- Enable FP16 or INT8 if accuracy allows.
- Fuse ops / use compiled graphs where possible.
- Keep the model on GPU memory; avoid CPU↔GPU transfers in the request path.
2) Batching strategy
- For low latency, use dynamic micro-batching with a very small max delay (e.g. 1–5 ms).
- Prefer adaptive batching over large fixed batches.
- Separate latency-sensitive and throughput-oriented traffic if possible.
3) GPU utilization
- Use pinned host memory and async copies.
- Pre-warm the model and allocate all buffers up front.
- Avoid frequent GPU memory allocations; use memory pools.
- If applicable, use CUDA streams to overlap transfers and compute.
4) Serving architecture
- Keep the request path short: API gateway → inference worker.
- Use one process per GPU or carefully managed multi-stream concurrency.
- Load balance across replicas using consistent hashing or least-loaded routing.
5) Tail-latency controls
- Set request timeouts and queue limits.
- Drop or degrade gracefully under load.
- Instrument p50/p95/p99 latency separately.
- Watch for contention from preprocessing/postprocessing on CPU.
6) Observability
- Track:
- queue time
- GPU compute time
- H2D/D2H transfer time
- batch size
- GPU memory usage
- SM utilization / occupancy
- Add tracing per request to find bottlenecks.
7) Common pitfalls
- Oversubscribing a GPU with too many concurrent requests.
- Large batches that improve throughput but hurt p99.
- Python overhead in the hot path.
- Repeated tokenizer/preprocessing work on the critical path.
- Cold starts and lazy initialization.
If you want, I can help you design:
- a GPU serving architecture,
- a latency optimization plan, or
- a benchmarking methodology for p50/p99 on your specific model.