MachGen.com

Performance guide

Where inference latency goes

A user experiences the whole wait between submitting a request and receiving something usable. A fast model is one part of that path. To improve an application, first write down exactly where your timer starts and stops.

Give each stage a budget

Imagine an image editor with a target of two seconds from clicking Generate to displaying a completed image. An illustrative budget might allocate 150 milliseconds to request handling, 250 to waiting, 1,200 to generation, and 400 to transfer and display. The numbers are a planning example, not benchmark results.

Measure the actual stages before changing the model. If waiting consumes most of the budget, shortening image download time will have limited effect. If the final file arrives quickly but takes time to display, inspect the client’s work as well as the server.

Optimize the constrained stage

For model execution, PyTorch documents ways to reduce unnecessary work: disabling gradient calculation during ordinary inference saves memory and computation, while fusing compatible operations can reduce memory traffic and kernel launches. Applicability depends on the workload. See the PyTorch performance tuning guide.

For scheduling, batching presents a tradeoff. Triton can combine requests to increase throughput and optionally wait for a fuller batch. That delay belongs in the request’s latency budget. NVIDIA recommends measuring latency and throughput while tuning batching settings. See the Triton batcher documentation.

Test the interaction you intend to ship

Choose changes based on the stage that misses its budget. Then rerun the complete interaction to verify that the user’s wait improved. The benchmarking guide explains how to make that comparison repeatable; the cost guide helps check its economic effect.