Forward pass
A forward pass is one run of input data through a neural network, layer by layer from input to output, to produce a prediction.
In a forward pass, data flows one way through a network. The first layer takes the input, combines it with its weights and passes the result on; each following layer does the same with the output of the one before, until the final layer produces an answer. For a large language model, one forward pass over the text so far produces a probability for every possible next token.
Training alternates the forward pass with a backward pass. The forward pass makes predictions and measures the error against the right answers; the backward pass, backpropagation, then works from the output back towards the input to calculate how each weight should change. The backward pass needs intermediate values from the forward pass, so those have to be kept in memory until it runs, which is one reason training needs more memory than simply running a model.
Using a trained model, inference, is forward passes alone, with the weights held fixed. A chatbot writes its reply one token at a time, and each new token requires another forward pass, which attends to everything written so far. That is why long answers cost more and take longer than short ones.
The arithmetic is well understood. In their 2020 paper on scaling laws, Jared Kaplan and colleagues estimated that a forward pass of a transformer takes roughly 2N operations per token, where N is the number of parameters outside the embedding layers. The backward pass takes about twice as much again, which gives the widely used rule of thumb that training costs about 6N operations per training token.
Counting forward passes is a simple way to read AI efficiency claims. When Prafulla Dhariwal and Alex Nichol reported in 2021 that their diffusion model matched a leading GAN with as few as 25 forward passes per image, they were describing cost: fewer passes means faster, cheaper generation. Techniques such as speculative decoding, distillation and smaller models are all, in the end, ways of making each forward pass cheaper or needing fewer of them.
The forward pass runs input through the network to produce an output and, in training, a measure of error. The backward pass runs from the output back to the input to work out how each weight contributed to that error. Training needs both; using a finished model needs only the forward pass. Essentially yes. Inference means running a trained model with its weights fixed, which is a forward pass. Generating text takes many forward passes, one for each new token, while a classifier may need only one. For a transformer, Kaplan and colleagues estimated roughly two operations per parameter for each token processed, ignoring the embedding layers. A model with 70 billion parameters therefore needs on the order of 140 billion operations per token, before counting the extra cost of attention over long inputs. Because each new token needs its own forward pass through the whole model. A 1,000-token answer needs about a thousand passes, while a 100-token answer needs about a hundred, so output length drives both cost and waiting time.Common questions
What is the difference between a forward pass and a backward pass?
Is inference just a forward pass?
How much computation does a forward pass take?
Why does generating a long answer cost more?
Search for "forward pass vs backward pass", "backpropagation explained" or "transformer FLOPs per token" to see how the computation is counted. Reliable sources include machine learning courses and glossaries, framework documentation for tools such as PyTorch, and research papers on arXiv that state their compute estimates. Be careful with headline speed figures, since they depend on hardware, batch size and input length.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.