Series · 11 posts

From PyTorch to Deployment

ONNX export, quantization, preprocessing bugs, inference threading, batching curves and CPU-vs-GPU serving, measured with latency and accuracy numbers.

What actually breaks and what actually costs between a trained PyTorch model and a model serving requests: export failures, quantization results that contradict the brochure, preprocessing mistakes ranked by damage, and the serving curves that decide between CPU and GPU.

  1. 1
    Quantization for Edge Devices: Lessons From Real Hardware
    July 15, 2026
    Quantization for Edge Devices: Lessons from Deploying on Real Hardware

    PTQ vs QAT, memory layouts and the hardware constraints that only show up on deployment day, from models on embedded targets.

  2. 2
    What Breaks When Exporting PyTorch Models to ONNX
    July 21, 2026
    What Actually Breaks When You Export PyTorch Models to ONNX

    Four ONNX export failures reproduced on a real machine: fixed batch sizes, baked-in branches, unsupported ops and a Windows crash, with fixes.

  3. 3
    ONNX Quantization Measured: Size, Latency, Accuracy
    July 22, 2026
    Quantizing an ONNX Model in Practice: The Numbers Nobody Shows You

    A real model quantized with onnxruntime and measured on file size, latency and accuracy. Dynamic quantization made the CNN 3x slower.

  4. 4
    Image Preprocessing Bugs Ranked by Accuracy Cost
    August 20, 2026
    Quantization Cost My Model 0.13 Points. Preprocessing Bugs Cost Up to 72

    BGR order, missing normalization, wrong stats, JPEG artifacts and resize errors injected one at a time. The costliest bug took 72 points.

  5. 5
    Forgetting model.eval() in PyTorch: The Measured Cost
    August 24, 2026
    Forget model.eval() and Your Accuracy Depends on Your Traffic

    Train-mode batch norm scores chance on single requests and looks fine at batch 256, which is why load tests miss it. Plus what no_grad really buys.

  6. 6
    ONNX Runtime CPU Inference Threading, Measured
    August 25, 2026
    CPU Inference Threading: The Default Grabs Every Core and Still Loses

    Latency vs thread count for a 103 KB and a 43 MB model, then eight single-threaded sessions against one default session: 1.7x the throughput.

  7. 7
    Golden-Sample Tests for ML Models: Choosing the Tolerance
    September 1, 2026
    The Twenty-Line Test I Kept Promising, and the Tolerance That Makes It Work

    Legitimate variation moved logits by at most 0.006; the weakest injected bug moved them 1.15. That 190x gap is where the golden-sample test lives.

  8. 8
    GPU Inference Batching Curve: Batch 1 to 256, fp32 and fp16
    September 2, 2026
    Batch 1 Uses 8% of Your GPU, and Other Things the Batching Curve Says

    Batch size swept 1 to 256 over three model sizes on an RTX 4080 SUPER. The first eight images are free and fp16 is slower until batch 16.

  9. 9
    ONNX Runtime Graph Optimization Levels, Measured
    September 22, 2026
    ONNX Runtime's Optimization Levels Do Completely Different Things to Different Models

    Across three models: int8 is a 3.4x win that collapses if optimization is off, ResNet18 gets 35% from layout and almost nothing from fusion.

  10. 10
    CPU vs GPU Serving Latency: Where the Crossover Is
    September 23, 2026
    The GPU Has a 0.8 ms Floor, and My Sensor Model Lives Under It

    Four model sizes on ONNX Runtime CPU vs PyTorch fp16 GPU. At batch 1 the tiny IMU model is 11.7x faster on CPU; one batch later, GPU wins 62x.

  11. 11
    TTA Serving Cost: Ten Views for 8% With Concatenated Batches
    October 22, 2026
    One Good Question Repriced TTA: Ten Views Now Cost 8%

    Sequential TTA pays 2x for a flip and 10x for ten views at every batch size. Concatenated TTA rides the GPU overhead floor: ten views cost 8%.