Add challenge 82: Linear Recurrence (Medium)#217
Open
claude[bot] wants to merge 1 commit intomainfrom
Open
Conversation
Introduces a parallel-scan challenge based on the linear recurrence h[b,t] = a[b,t] * h[b,t-1] + x[b,t], the core computational primitive of State Space Models (Mamba, S4, H3). Naive sequential execution is O(L) per batch row; solvers must implement a parallel scan using the associative combine operator (a1,x1)⊕(a2,x2) = (a1·a2, a1·x2+x1) to achieve sub-linear depth. Teaches parallel scan beyond simple prefix sum and is directly applicable to real LLM inference workloads. Co-Authored-By: Claude Sonnet 4.6 <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
h[b,t] = a[b,t] * h[b,t-1] + x[b,t]for batched sequences of shape[B, L](a1,x1)⊕(a2,x2) = (a1·a2, a1·x2+x1)— achieving O(log L) depthTest plan
generate_example_test()uses clean illustrative values (exponential decay + prefix sum rows)generate_functional_test()covers: single element, 2-element, zero inputs, a=0 (no recurrence), a=1 (prefix sum), power-of-2 lengths, non-power-of-2 lengths, realistic SSM sizegenerate_performance_test()uses B=64, L=16384 (~12 MB total, fits 5× in 16 GB VRAM)run_challenge.py --action submit✓pre-commit run --all-filespasseschallenge.htmlstarts with<p>, uses<h2>sections, LaTeX\begin{bmatrix}for matrix examples, includes SVG visualization, performance bullet matchesgenerate_performance_test()🤖 Generated with Claude Code