Row-wise softmax
×Convert each query row into normalized attention weights.
- in
- [B batch, 32 q heads, 1 query, 1001 keys]
- out
- [B batch, 32 q heads, 1 query, 1001 keys]
In float32, then cast back to the query type.
Explanation
, , and index batch, head, query and key; runs over the keys.
Sources
In codeF.softmax(scores.float(), dim=-1).type_as(xq)
Direct evidence
Softmax normalizes the last score axis in float32 and restores the query dtype.
model.py 187 ↗ · meta-llama/llama3 @ a0940f9cf706
Excerpt
scores = F.softmax(scores.float(), dim=-1).type_as(xq)