Module 12. Diffusion Language 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. Parity in the generic dense-8B scenario
Derive the largest integer number of calls for which full-canvas diffusion remains above the batch-one AR ceiling.
Show answer and solution
Solution. AR emits one token per pass, so its ceiling is tok/s. A diffusion model reveals a 1,024-token canvas in full passes, giving average rate . It is faster when
This gives , so the largest integer is 295; at 296 calls it has already fallen below the AR boundary in this arithmetic model.
E2. Dense arithmetic versus DiffusionGemma
Reproduce the bf16 and idealized four-bit lower bounds for a dense 8B block of 256 positions. Explain why neither describes DiffusionGemma.
Show answer and solution
Solution. Eight billion dense weights occupy GB in bf16 and GB at ideal four-bit packing. At 3.35 TB/s, one weight read takes ms or ms. A 256-position pass has dense arithmetic floor
The bf16 case is therefore memory-limited by the larger 4.776-ms floor, while ideal four-bit weights expose the 4.137-ms compute floor. These are lower bounds, not their sum under perfect overlap.
DiffusionGemma is instead a 25.2B-total/3.8B-active sparse MoE. Different canvas positions can select different experts, so one pass may read the union of many experts; tensor precisions are heterogeneous and runtime placement matters. Its H100 result uses FP8, while NVFP4 refers to Blackwell. Dense-8B arithmetic therefore cannot be relabeled as a DiffusionGemma prediction.
E3. Read speed claims as passports
Compare Mercury 2’s 1009 tok/s on Blackwell, Gemini Diffusion’s 1479 tok/s excluding 0.84 s overhead, and Seed Diffusion’s 2146 tok/s on H20 coding workloads.
Show answer and solution
Solution. There is no defensible winner without a shared model-quality target, prompt/output distribution, batch size, precision, sampler, and end-to-end latency boundary. Gemini makes the boundary issue explicit: for output tokens, a scenario that applies its reported averages to that length gives approximately seconds, so 1,479 tok/s is not the end-to-end rate of a short response. A matched comparison should report time to first token, complete-request latency, and steady-state throughput separately.
E4. Block mask
Construct the attention mask for a three-token completed prefix and a four-token current block. Identify the cacheable rows.
Show answer and solution
Solution. With rows and columns ordered P1 P2 P3 B1 B2 B3 B4, the allowed mask is
P1 1 0 0 | 0 0 0 0
P2 1 1 0 | 0 0 0 0
P3 1 1 1 | 0 0 0 0
-------+--------
B1 1 1 1 | 1 1 1 1
B2 1 1 1 | 1 1 1 1
B3 1 1 1 | 1 1 1 1
B4 1 1 1 | 1 1 1 1Prefix queries are causal and independent of the active block, so their K/V can be reused across denoising steps. Every active-block query reads the complete prefix and block; when masks change, those four states must be recomputed.
E5 [project]
Train a small character-level masked-diffusion Transformer and compare random, confidence, and entropy reveal policies at equal model-call budgets.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 12, section “Demo 1”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.
E6 [project]
Start with the demo’s work ledger. Vary block length and denoising steps, including the separate clean-block pass. Compare model calls and positions processed, then estimate weight bytes for a hypothetical dense model under one full weight read per call. On the tiny trained CPU model, measure quality and latency, reporting thread count, warm-up, and repetitions. Explain why estimated bytes are not measured traffic. Hardware memory profiling is an optional extension.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 12, section “Demo 2”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.