Read the equation
In DeepseekV3Attention.forward, this statement defines or updates attn_weights. Softmax exponentiates and normalizes scores along the chosen axis, producing nonnegative weights that sum to one when inputs are finite. The matrix or indexed contraction combines the stated axes. Compatible tensor dimensions and the transposes in this exact source expression determine the output.
Terms & definitions
The recovered passage does not supply a separate symbol table. Read the source context for the notation used in this version; familiar letters may carry different meanings in other builds.
How it works
Read attn_weights as the quantity being defined or updated by this relation.
Substitute the source-defined variables or recorded values and follow the displayed arithmetic and indexing exactly.
Use this version’s variable definitions and update order. The same symbol may be assigned a different meaning in another build.
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
key_states, value_states = past_key_value.update(
key_states, value_states, self.layer_idx, cache_kwargs)
attn_weights = (
torch.matmul(query_states, key_states.transpose(2, 3)) *
self.softmax_scale)
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
raise ValueError(Exact original notation
attn_weights = (
torch.matmul(query_states, key_states.transpose(2, 3)) *
self.softmax_scale)Related builds
Sources & provenance
attn_weights = ( torch.matmul(query_states, key_states.transpose(2, 3)) * self.softmax_scale)
attn_weights = ( torch.matmul(query_states, key_states.transpose(2, 3)) * self.softmax_scale )