Custom Attention Kernel Survives 32k Tokens Where Standard PyTorch OOMs — 11x Faster

vankownlaw · reddit · 2026-11-04

The author built a custom attention kernel for long-context that mimics human memory: early tokens are kept as "sinks" (core memories), with a rolling window and entropy decay for the rest. Benchmarked on a Tesla T4:

They note FlashAttention still scales quadratically in memory, whereas this approach physically never stores the full NxN matrix — and invite feedback on where to improve.

Related event: 15-year-old builds attention kernel: no OOM at 32k, 11x faster(2 posts)→

Original post →

More from Research

Research channel →