liveBook · Manning

Triton.testing.do_bench

As explained in GPU Programming with Triton

triton.testing.do_bench is a Triton benchmarking utility that performs warmup, synchronized timing, repetition, and runtime summarization for a callable.

Use `triton.testing.do_bench` to measure a GPU callable without mistaking Python launch time for GPU execution time. GPU launches are asynchronous, and the first call may also include one-time compilation; verify correctness separately and exclude that first-call cost from the measurement. section 2.2.10 section 2.2.10

triton.testing.do_bench(
    fn,
    warmup=25,
    rep=100,
    grad_to_none=None,
    quantiles=None,
    return_mode='mean',
)

The interface exposes warmup and repetition counts, optional quantiles, and a return mode. section 2.2.10

How GPU Programming with Triton covers it

How deep it goes
Explains asynchronous timing pitfalls and presents the benchmark interface, without detailing its implementation.
Examples
Uses vector addition to illustrate correctness checks and GPU timing.
What it assumes
Assumes a callable GPU kernel and explains why asynchronous launches make naive wall-clock timing unreliable.
What you can do after
Apply `triton.testing.do_bench` to measure a callable while accounting for warmup and repeated runs.
How it connects
Connects GPU asynchronous execution, kernel compilation, and correctness checking.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of GPU Programming with Triton. The section links point to the parts of the book it draws on.