CourseTransformers: From Attention to Trained, Served and Interpreted Models · Module 10: Efficiency and Long Context · part 75 of 111
Part 75 · Module 10: Efficiency and Long Context

Lab: Efficient attention, KV cache and long-context probes, tested

35 min read·13 Oct 2026
Module 10 · Lab · About 60 minutes · Needs: lessons 1 to 4 of this module, and Module 8's lab

What you are building

TINYFORMER-LAB AFTER MODULE 10 attention_variants.py patterns, kernels kvcache.py size, batch, shrink longctx.py probes, retrieval v0.8.0 package: data, model, trainer, unchanged test_m10_efficiency 9 tests m10_efficiency run cost, cache, report card git tag v0.10.0
The lab adds three files (blue) to the unchanged v0.8.0 package (grey), pins them with nine tests (green), saves one measured run (amber) and tags v0.10.0.

Sol 431 at Aurora Station. Tariq Haddad's relay still splits long transmissions, and the four lessons answered him in notebook cells: sparse and banded attention (Lesson 1), linear attention (Lesson 2), tiled attention and the KV cache (Lesson 3), and a report card for long reads (Lesson 4).

Today those cells become three files in tinyformer-lab: attention_variants.py, kvcache.py and longctx.py. Course-guide/03 lists the first two for this module but gives Lesson 4's probes no home, so this lab chooses one: tinyformer/longctx.py. You pin the claims with nine tests, rerun the module's main table from the package, and tag v0.10.0.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.