Each row of the post-softmax attention weight matrix corresponds to which side of the QK product?
Each row corresponds to one query token; entries along the row are that token's weights over all key tokens; row sums to 1 because softmax normalizes per row.
Picture a table where each row belongs to one person who is asking a question. That row lists how much attention this person pays to every other person in the room. The numbers in the row are slices of a pie that has to add up to a whole pie, because the person is dividing 100 percent of their attention across the room. Different rows belong to different askers, each splitting their own pie independently.
Detailed answer & concept explanation~5 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4m: matrix shape from QK^T, softmax along the key axis, row-sum-to-1 invariant, mask interaction, decode-time degenerate case, and operational consequences for visualization and FlashAttention.
Real products, models, and research that use this idea.
- Attention visualization tools like BertViz and the HuggingFace inspect APIs all use the row=query, column=key convention.
- FlashAttention 2 and 3 tile over rows of Q in the outer loop, processing one query block at a time against streamed K blocks.
- Llama 4 Maverick's GQA still has the same row-sum-to-1 invariant per query head, even though multiple query heads share KV heads.
- Sliding-window attention in Mistral and similar models defines a mask that keeps only nearby columns per row; row sums still equal 1 over the window.
- StreamingLLM with attention sinks keeps the first few key columns plus a sliding window; rows sum to 1 over sink + window positions.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat changes about the matrix during autoregressive decoding when T_q equals 1?
QHow does the row convention interact with multi-head attention?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Swapping rows and columns. Rows index queries (who is asking) and columns index keys (who is being asked about). Flipping this breaks every subsequent operation.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.