How does attention-memory cost change when context length doubles?
Instruction: For one layer and one attention head, suppose a naive implementation materializes a dense n×n attention-score matrix in float32. Calculate storage at n=2,048 and n=4,096, using 1 MiB=2^20 bytes. Explain what these numbers do and do not imply for real transformer training and autoregressive decoding.
Context: Use a bounded transformer calculation to separate dense attention scaling from total memory and serving behavior.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
At 2,048 tokens there are 2,048²=4,194,304 elements; four bytes each gives 16 MiB. At 4,096 tokens there are 16,777,216 elements, or 64 MiB. Doubling sequence length quadruples this particular dense matrix.
This is one head and layer's score storage, not total model memory...