Understanding LLM Inference: Autoregressive Generation and Speculative Decoding

Abhishekcur · x · 2026-08-10

This post breaks down the core mechanics of LLM inference. In standard, non-speculative decoding, the model operates autoregressively, predicting one token at a time: it predicts the next token, appends it to the sequence, and runs another forward pass. With KV caching, it avoids recomputing previous keys and values from scratch.

This loop repeats until the model produces an EOS token or hits a length limit. Thus, the maxtokens parameter acts as an upper bound on generation, not a target.

The author explains how speculative decoding optimizes this execution loop by proposing multiple tokens and verifying them with the target model, while the underlying autoregressive generation semantics remain the same.

Original post →

More from Research

Research channel →