Fix incorrect Example 2 output in Causal Self-Attention - #331
Open
claude[bot] wants to merge 1 commit into
Open
claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
Example 2 in 53_casual_attention listed the output as [[3,4],[5,6]], which is just a copy of V. For Q = [[0,0],[1,1]], K = I, the second query's logits are both 1/sqrt(2), so row 1 attends to both keys with weight 0.5 and the correct output row is [4.0, 5.0]. Verified against reference_impl (causal mask, scale = sqrt(d), row-wise softmax); Example 1's published values reproduce exactly to 7 decimals under the same computation, which cross-validates the method. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
claude
Bot
requested review from
ishaan-arya,
kunal-mansukhani and
shxjames
as code owners
September 30, 2026 11:47
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while verifying the in-repo assets for
53_casual_attentionin response to #123 / #88.challenge.htmlExample 2 listed the output as a straight copy ofV:3.0 4.03.0 4.05.0 6.04.0 5.0For
Q = [[0,0],[1,1]],K = I,d = 2, query 1's logits areQ[1]·K[0] = Q[1]·K[1] = 1, so after scaling by1/sqrt(2)both keys are tied and neither is masked (j <= ifori = 1). Softmax gives[0.5, 0.5], hence0.5*[3,4] + 0.5*[5,6] = [4.0, 5.0].Verification
Recomputed both examples directly from
reference_impl's definition (causal mask,scale = sqrt(d), row-wise softmax). Example 1 reproduces the published values exactly —3.4898373vs the documented3.4898374— which cross-validates the computation; Example 2 does not.Example 1 is the one mirrored by
generate_example_test(), so this error was invisible to the test harness. Confirmed viarun_challenge.py --action run(T4): the example test passes unchanged, since it only covers Example 1.Docs-only change; no
challenge.pyor starter behavior is affected.🤖 Generated with Claude Code