Blogs / Why LLM Generation Cannot Be Parallelized Per Request

Why LLM Generation Cannot Be Parallelized Per Request

What a Hugging Face post says about how LLMs generate text token by token and why that cannot be parallelized inside one request.

  • Learning
  • 1 min read

For: Learners who know what an LLM is.

How LLMs generate text

Most LLMs generate text token by token, which guarantees that every new token is computed based on all preceding tokens (this model property is called auto-regressive).[1]

What each token depends on

The first output token depends on all prompt tokens, but the second output token already depends on all prompt tokens plus the first output token, and so on.[1]

Text generated tokenby tokenauto-regressiveEach new tokendepends on allpreceding tokensthe second output tokenincludes the firstNo parallelizationwithin one requestfor token generationguaranteesso
Why can tokens not be generated in parallel?

What follows

As a consequence, token generation cannot be parallelized at the level of an individual request.[1]

Sources

  1. Prefill and Decode for Concurrent Requests (huggingface.co · checked )

More articles