Add challenge 107: Hadamard Transform (Medium)#286
Open
claude[bot] wants to merge 1 commit into
Open
Conversation
Adds a batched Walsh-Hadamard transform challenge: solvers compute the orthonormal Hadamard transform of each row of a (B, N) matrix where N is a power of two. The fast butterfly schedule (O(N log N), log2 N stages with __syncthreads between them) is a real-world inference kernel used in QuaRot/QuIP# style activation rotations for low-bit LLM quantization. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
(B, N)matrix, whereNis a power of two, using the fast butterfly schedule (O(N log N)).__syncthreads()between thelog2(N)butterfly stages — meaningfully harder than an elementwise op, simpler than a full FFT.Files
challenges/medium/107_hadamard_transform/challenge.py— reference impl (pure PyTorch view/add/sub, works on CUDA and XLA), 10 functional tests coveringN = 1, 2, 4, 16, 8, 32, 128, 1024, 64, 2048with zeros, constants, mixed signs, and large rows.challenges/medium/107_hadamard_transform/challenge.html— problem statement with recursiveH_Ndefinition and stage-by-stage worked example..cu,.pytorch.py,.triton.py,.jax.py,.cute.py,.mojo).Validation
pre-commit run --all-files— passes.H @ H = I, constant rows produce a single non-zero coefficient at index 0, example[1, 2, 3, 4] → [5, -1, -2, 0].scripts/run_challenge.py --action submiton a T4 — all tests pass.Test plan
pre-commit run --all-filesclean