Truncated BPTT and Window Length
Instead of backpropagating gradients through an entire long sequence, truncated BPTT only unrolls and grades the last k steps at a time, trading how far back credit can flow for tractable memory and compute.
Prerequisites: Backpropagation Through Time, Recurrent Neural Networks
Backpropagation through time unrolls a recurrent network across every timestep of a sequence and backpropagates the full chain of gradients from the last step all the way to the first. For a sequence of a few hundred or a few thousand steps — a year of daily bars, a day of minute bars — that means storing and differentiating through the entire unrolled chain at once, which is both memory-expensive and prone to vanishing or exploding gradients over such a long path.
The analogy: grading only the recent pages
Being graded on every single page of a year-long diary at once, all in one sitting, is impractical. Truncated BPTT instead only unrolls and grades the last pages at a time: the hidden state still carries forward continuously from page to page, but the gradient — the "grading" signal — only ever looks back pages before it stops.
The mechanics
Full BPTT differentiates the loss at time with respect to every parameter through the entire chain back to . Truncated BPTT (TBPTT) instead splits the sequence into chunks of length : within a chunk, it runs the forward pass and a full backward pass just for those steps, then carries the hidden state — but not its gradient history — forward into the next chunk as a fixed starting point.
In a simplified linear recurrence, for some effective decay factor , the contribution of an input from steps back to today's gradient scales roughly like — restating: the further back a timestep is from the current truncation window, the more its gradient contribution has already decayed, so the window length directly controls how far back the network can be taught to look.
Worked example 1: chunk boundaries
A sequence of length with window splits into 4 chunks: steps 1–5, 6–10, 11–15, 16–20. Gradients computed during the chunk covering steps 11–15 never flow back past step 11 — no matter how relevant step 3 might have been, no credit or blame reaches it during that chunk's backward pass.
Worked example 2: how much of the past still gets credited
Take a toy recurrence , where is the effective decay per step. The gradient contribution from an input steps back scales like . With : — nearly three-quarters of the signal from 3 steps back still reaches today. With : — only about a third survives from 10 steps back. Choosing window length this small effectively caps how far back the network is trained to notice anything, regardless of the sequence's true length.
The gradient contribution from k steps back decays exponentially with the decay factor raised to the k-th power — exactly the shape below:
Truncated BPTT unrolls and backpropagates only k steps at a time to keep training tractable, letting the hidden state carry information forward indefinitely while gradients only ever teach the network to use roughly the last k steps of context.
What this means in practice
Window length is chosen based on how far back dependence plausibly matters for the task — a few days for a fast mean-reverting signal, weeks for a slower trend — balanced against GPU memory and training speed, since a longer means a longer chain to store and differentiate per chunk.
Truncating the gradient is not the same as truncating memory. The hidden state itself can still, in principle, carry information across chunk boundaries indefinitely — it just never gets actively taught to rely on anything beyond roughly steps back, because no gradient signal ever reaches that far. A model can therefore behave as if it has a hard k-step memory limit even though nothing architecturally prevents longer-range state from persisting.
Related concepts
Practice in interviews
Further reading
- Williams & Peng, An Efficient Gradient-Based Algorithm for On-Line Training of Recurrent Network Trajectories (1990)