LLM Fine-Tuning, Compiling and Serving Benchmarks
A platform team was guessing at serving choices. I built a reproducible harness that fine-tunes open-weight models with LoRA and RLHF, compiles them through multiple runtimes, and measures throughput, latency, and quality on identical hardware so decisions rest on numbers.
- 48
- Serving configs benchmarked
- 5.8x
- Throughput gain
- -71%
- Cost per 1M tokens
- 99.2%
- Quality retained
The challenge
Published benchmarks never matched the team's traffic shape. Long prompts, bursty concurrency, and strict tail-latency targets meant a config that looked fastest in isolation was often the worst choice in production.
Approach
- Built distributed fine-tuning on Ray with Horovod-based data parallelism, LoRA adapters for cheap task iteration, and a full RLHF stage with reward-model training and preference optimisation.
- Wrote custom CUDA C++ kernels for the attention and sampling hot paths, then validated numerical parity against the reference implementation before adoption.
- Compiled each checkpoint through ONNX Runtime, TensorRT-LLM, and vLLM at multiple quantisation levels, holding hardware, tokeniser, and prompt mix constant across runs.
- Replayed production traffic traces instead of synthetic uniform load, reporting throughput against P99 latency so tail behaviour is visible rather than averaged away.
- Published every result as a versioned artefact with the exact commit, driver, and container digest, making regressions attributable to a single change.
Outcome
The selected TensorRT-LLM configuration delivered 5.8x the baseline throughput at the team's P99 target, cutting cost per million tokens by 71% while retaining 99.2% of evaluation quality. The harness is now a merge gate for serving changes.
Results in detail
Figures are from the delivered engagement, normalised where data is confidential.
Throughput by serving runtime
Output tokens/second at a fixed P99 latency target, same GPU and traffic trace.
Throughput vs. tail latency frontier
Each point is a concurrency level; the frontier shows where tail latency breaks down.
Quality retained after quantisation
Aggregate eval score relative to the FP16 fine-tuned checkpoint.
Related projects
Fintech / Credit risk
Causal Auditing of RL Loan Pricing Policies Using Process Mining
Auditing a reinforcement-learning pricing agent for fairness and causal soundness with event-log mining.
Automotive / Supply chain quality
Weakly-Supervised Anomaly Detection for Supply Chain Operations
A hybrid deep-learning and classic-ML anomaly detection platform that flags supply-chain irregularities and recommends classification.