Grouped-query attention

Reference code meta-llama/llama3 @ a0940f9, configuration meta-llama/llama-models @ 0e0b8c5 · checkpoint, tokenizer and tensors not verified · How to read

32 independent transformer blocks › Attention

Attention weights

×

tensorscores · 187

Normalized weights over the allowed key positions for each query.

shape
AA [B batch, 32 q heads, T queries, T keys]
Codemodel.py 187
model.py 187
        scores = F.softmax(scores.float(), dim=-1).type_as(xq)
Sources1

Contextual evidence

Softmax normalizes the last score axis in float32 and restores the query dtype.

attn-softmax · meta-llama/llama3 / llama/model.py
Pinned revision a0940f9cf706 ↗ · lines 187–187

Read code excerpt
        scores = F.softmax(scores.float(), dim=-1).type_as(xq)