Restrict each token to a local causal band. This page uses readable dense reference code and explains the optimized O(T·W) kernel separately.
Longformer · Beltagy et al.