Skip to content

Add challenge 110: Attention with Sinks (Medium)#292

Open
claude[bot] wants to merge 1 commit into
mainfrom
add-challenge-110-attention-with-sinks
Open

Add challenge 110: Attention with Sinks (Medium)#292
claude[bot] wants to merge 1 commit into
mainfrom
add-challenge-110-attention-with-sinks

Conversation

@claude

@claude claude Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds challenge 110 (Medium): Attention with Sinks, a StreamingLLM-style attention variant where each query attends to a small set of leading sink tokens plus a causal sliding window of the most recent tokens.
  • Real-world inference kernel used to bound the KV cache for long-context streaming while preserving the anchor tokens that stabilize the softmax distribution.
  • Distinct from the existing sliding-window, causal, and window-cache challenges: the mask combines a fixed leading prefix (sinks) with a moving window plus a causal constraint, producing a two-region attention pattern that neither sliding-window nor plain causal attention captures.

Files

  • challenge.py — reference implementation, ctypes signature, 10 functional tests, perf test (M=5000, d=128, num_sinks=4, window_size=1024).
  • challenge.html — problem description, SVG mask visualization, example matching generate_example_test, constraints with performance-test parameters.
  • starter/ — CUDA, PyTorch, Triton, JAX, CuTe, Mojo starters that compile but do not solve.

Test plan

  • Reference impl runs on all 10 functional tests locally (CPU, all outputs finite).
  • Example output values in challenge.html match reference_impl numerically.
  • pre-commit run --all-files passes (black, isort, flake8, clang-format, mojo).
  • Sample CUDA solution submitted via scripts/run_challenge.pyAll tests passed on Tesla T4 (functional + performance).
  • Reference impl uses only standard PyTorch ops (works on CUDA and XLA — no torch.cuda.*, no CUDA-only kernels).
  • All tensor allocations use device=self.device.

🤖 Generated with Claude Code

Adds a StreamingLLM-inspired attention variant where each query
attends to a small set of leading sink tokens plus a sliding causal
window of the most recent tokens. Includes reference implementation,
tests, and starter templates for all six frameworks.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants