Module 8. Beyond the Transformer: SSMs, Mamba, and Hybrid Sequence Models
Try each exercise first. Expand worked answers or project guidance when needed; their open state is shared between RU/EN.
Download course files (.zip) 2588.1 KBThe archive preserves the source folder structure, both languages, and supporting files.
E1. Approximation threshold
For , solve for the step at which replacing the exact ZOH input coefficient with creates ten-percent relative error.
Show answer and solution
Solution.
For , exact ZOH discretization gives input coefficient . With and , this is , whereas the small-step approximation uses . Hence relative error against the exact coefficient is
Substitution gives . The small- expansion starts with error , so a root near 0.2 is also a useful magnitude check.
E2. Complete recurrent cache
For 32 layers, , , , and bf16, compute the two state components and the crossover against 128 KiB/token.
Show answer and solution
Solution. One layer's SSM state has bf16 elements:
Across 32 layers this is 8 MiB. Convolution state uses elements: bytes per layer, or 2 MiB total. Complete recurrent cache is 10 MiB and does not grow with sequence length. At 128 KiB/token, KV reaches it at tokens and exceeds it afterward.
E3. Mamba-2-like cache
Set and convolution channels to . Find the complete cache and the first integer token beyond crossover.
Show answer and solution
Solution. The SSM component is
Convolution has channels, so its state uses MiB. Total is 66.0625 MiB. Dividing by 0.125 MiB of KV per token gives 528.5: KV is still smaller at 528 tokens and first becomes strictly larger at 529.
E4 [project]
Compare sequential and chunked scans at a sequence length not divisible by the chunk size. The partial final chunk must agree with the reference recurrence.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 8, section “Demo 1”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.
E5 [project]
Compare additive, delta, and gated-delta memory on a synthetic task. Use identical keys, values, and state dimensions to compare interference, rewriting, and forgetting. Report current-key error separately from error over all previously written keys.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 8, section “Demo 2”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.