liveBook · Manning

Mean

As explained in Transformers in Action

A speedup is the ratio of the execution time of a baseline implementation to that of an optimized implementation.

A speedup compares baseline execution time with optimized execution time. In inference optimization, it measures how scheduling, memory access, caching, and GPU utilization reduce latency without changing model architecture. section 9.3

Interpret speedup through the optimization being compared:

  • KV caching avoids recomputing the full attention context during autoregressive generation by storing and reusing key and value vectors. section 9.3
  • Tiling, shared memory, coalesced access, operation fusion, and CUDA thread hierarchies improve GPU execution, with optimized kernels reported at 2x to 4x over naïve kernels. section 9.4

Measuring cached inference

A Hugging Face Transformers benchmark runs Llama 3.2 3B Instruct with use_cache enabled and disabled, records generation durations, and compares the resulting latency. section 9.3

Figure 9.4 At each step, the query is computed for the new token, while past key and value vectors are cached and reused. This avoids recomputation of the entire attention context, dramatically reducing inference time.
figure

The figure traces autoregressive generation: each new token computes a query while reusing previously cached key and value vectors. section 9.3

How Transformers in Action covers it

How deep it goes
Explains latency benchmarking, KV-cache reuse, and GPU optimization, but stops short of deriving a statistical mean.
Examples
Uses Llama 3.2 3B timing comparisons and reports 2x to 4x gains from optimized GPU kernels.
What you can do after
Evaluate inference optimizations by comparing measured execution durations with and without caching or optimized kernels.
How it connects
Connects speedup with inference optimization, latency, KV caching, CUDA, shared memory, vLLM, and TensorRT-LLM.

Also explained in

Compare how 29 books explain mean →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Transformers in Action. The section links point to the parts of the book it draws on.