Skip to content
nonconvexcard

Count the FLOPs of a forward pass

NumericalFoundation⏱ 15 minLLM Opsflopscountingprefill

Problem

A decoder-only transformer has N=6.7×109N = 6.7\times10^9 non-embedding parameters, L=32L = 32 layers and width d=4096d = 4096.

  1. Compute the FLOPs of a forward pass over a 512-token prompt.
  2. Compute it over a 32,768-token prompt.
  3. In each case, give the fraction contributed by the attention score/value products.

Compute the requested quantities and say what they mean. A number without an interpretation is not an answer.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Adapter parameter countsFine-TuningNumericalFoundation15 min
Derive the attention crossover lengthLLM OpsProofBeginner15 min
Ridge point and the batch size needed to saturateLLM OpsNumericalBeginner15 min
The 6ND FLOP estimateLLMsNumericalBeginner15 min
When does attention dominate the MLP?Deep LearningNumericalBeginner30 min