Summary
Improve the GPT-2 attention demo from a correctness spike into a more realistic inference path: multi-head (or fused) kernels, KV cache support, and fewer launches per layer.
Motivation
Current demo limitations (demo/README.md):
- Batch size 1
- No KV cache (
use_cache=False) — full recompute every step
- Max sequence length 1024 (shared allocation)
- 12 kernel launches per layer (one per head)
That is enough to prove WarpForth can run real attention, but not enough to showcase competitive structure or exercise multi-buffer / multi-head patterns.
Proposed improvements (incremental)
- Fused multi-head kernel or grid mapping that covers all heads in one launch
- KV cache: accept K/V cache tensors and only compute the new row; update host patch to
use_cache=True
- Batch > 1 (even batch=2) to force batch indexing discipline
- Use Python package / metadata APIs when available instead of bespoke PyCUDA glue
- Document tokens/s before vs after on a fixed GPU SKU
Acceptance criteria
Non-goals
- Matching FlashAttention performance
- Full training support
Related
Summary
Improve the GPT-2 attention demo from a correctness spike into a more realistic inference path: multi-head (or fused) kernels, KV cache support, and fewer launches per layer.
Motivation
Current demo limitations (
demo/README.md):use_cache=False) — full recompute every stepThat is enough to prove WarpForth can run real attention, but not enough to showcase competitive structure or exercise multi-buffer / multi-head patterns.
Proposed improvements (incremental)
use_cache=TrueAcceptance criteria
Non-goals
Related