ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Normalize each query’s attention scores

Apply softmax across key positions for each query and head. The resulting nonnegative weights sum to one when a row has at least one finite eligible score. The source computes this normalization in float32 and then converts it to the query dtype; its eager…

Donor model implementationhistorical source recovered; expression not executed in this website audit
Learn with the Atlas

Understand the scale

See what normalization changes and which assumptions it introduces.

Open guided lesson
donor-eq-82dd00d784729esource-code mathematical expression
attnweights=nn.functional.softmax(attnweights,dim=−1,dtype=torch.float32).to(querystates.dtype)attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to( query_states.dtype)

Read the equation

Apply softmax across key positions for each query and head. The resulting nonnegative weights sum to one when a row has at least one finite eligible score. The source computes this normalization in float32 and then converts it to the query dtype; its eager implementation incorporates a mask beforehand.

Terms & definitions

TermMeaning in this source
probs

Per-query distribution over key positions

How it works

Read the definition from its right-hand expression to the quantity on the left. Its surrounding source records the intended input, state, or parameter context. Where the source leaves an operation unspecified, this page preserves that gap.

Assumptions & limits

Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.

Original context

Read the surrounding source passage
attn_weights = attn_weights + attention_mask

        # upcast attention to fp32
        attn_weights = nn.functional.softmax(attn_weights,
                                             dim=-1,
                                             dtype=torch.float32).to(
                                                 query_states.dtype)
        attn_weights = nn.functional.dropout(attn_weights,
                                             p=self.attention_dropout,
                                             training=self.training)
Exact original notation
attn_weights = nn.functional.softmax(attn_weights,
                                             dim=-1,
                                             dtype=torch.float32).to(
                                                 query_states.dtype)

Related builds

Sources & provenance

01
kimi source tree.txt
lines 3155–3158 · Aug 5, 2026
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to( query_states.dtype)
02
DEEPSEEK_R1_COMPLETE.txt
lines 2943–2945 · Aug 5, 2026
attn_weights = nn.functional.softmax( attn_weights, dim=-1, dtype=torch.float32 ).to(query_states.dtype)
03
kimi source tree.txt
lines 3155–3158 · Aug 5, 2026
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to( query_states.dtype)
04
DEEPSEEK_R1_COMPLETE.txt
lines 2943–2945 · Aug 5, 2026
attn_weights = nn.functional.softmax( attn_weights, dim=-1, dtype=torch.float32 ).to(query_states.dtype)

Search equations, builds, manuscript text, and recovered sources.