Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Why
Level 3's ViT reference sends
[batch, tokens, dim]into a sequence-first Transformer encoder. Attention mixes images along the batch axis, and the classification token never attends to the image tokens. The shipped default model returns identical outputs when its images are multiplied by 10 or replaced with zeros, so the evaluator accepts an input-independent candidate.The preceding patch construction also reshapes NCHW
unfoldresults without arranging the spatial patches and channels. An explicit spatial-slice reference finds 80 of 96 elements in the wrong token positions for a small RGB image pair.What changed
Use the existing
F.unfold(...).transpose(1, 2)path to form complete spatial patch vectors, then configure the encoder withbatch_first=True. These two changes restore the intended image-token boundary without adding dependencies or changing the shipped shapes, initialization arguments or input distribution.Addresses the ViT case in #172. The other models in that issue remain separate. #108's level-3 review requests fidelity to the named model architecture, and its current patch doesn't touch this reference.
Verification
mainat423217d9fda91e0c2d67e4a43bf62f96f6d104f1and pass with the patch. They execute the complete reference against explicit spatial patch slices and a sequence-first encoder with identical weights, including image/projection gradients and batch independence.224×224images,16×16patches, embedding dimension 512, six layers, eight heads and zero dropout. On H200, all five new scenarios pass and the original revision fails all five.eval_kernel_against_refaccepts an equivalent positive control in FP32, FP16 and BF16. A candidate that replaces every image with zeros changes from incorrect acceptance in all three precisions to rejection in all three.0.296030, and image gradients are nonzero. The full FP64 output and image gradient match the independent sequence-first oracle exactly. The observed FP32 image-gradient difference is approximately1.30e-6and remains a measured floating-point path difference.state_dictkeys, 20,480,522 parameters and same-seed initial parameter values are unchanged, and strict state loading succeeds. Ruff, formatting andgit diff --checkpass.Local execution used Python 3.10.21 and PyTorch 2.9.0. GPU execution used Python 3.10.20, PyTorch 2.9.0+cu128, CUDA 12.8 and one H200, with dependencies isolated in the run directory. AMD hardware and other GPU architectures remain unrun.
Reference version
This intentionally changes the reference outputs for level 3 problem 28. Existing solutions need correctness re-evaluation, and reference timings need regeneration for the new revision. The offline analysis currently matches timing records by filename, so old timing JSON must stay associated with its original reference revision. No speedup is claimed for this semantic correction. The Hugging Face dataset has its own publication step and is unchanged by this repository patch.