English | 简体中文
Follow a token through matrices, attention, expert routing, text generation, GPU and Apple Neural Engine execution, caching, parallel scheduling, and speculative verification.
Sixteen chapters and fifty-six steps, with live numerical examples, teaching code, search, a formula reference, quick checks, and saved progress. Moving a slider recalculates the example. The site opens in English; readers can switch to Chinese, and their choice is remembered.
Requires Node.js 20+. The site has no runtime dependencies.
npm run dev
# http://127.0.0.1:5174
npm test
npm run check
npm run build
# Publish the contents of dist/ to a static directory.For browser checks, run npm ci, keep the development server running, and run npm run test:browser. On macOS the test uses installed Chrome; on other systems, first run npx playwright install chromium. Set SITE_URL to test a deployed site.
All assets use relative paths and lessons use hash routes, so subdirectories such as /games/inside-llm/ work without SPA rewrite rules. No external fonts, CDN dependencies, model API calls, or analytics are used. Preferences and progress stay in localStorage.
- Small matrices are teaching examples computed in JavaScript. The browser does not run the full model or access your ANE.
- Model dimensions refer to
qwen3.6-35b-a3b-oq4e-mtp, not every LLM. - Diagrams consistently use
input [T,H] × W [H,O]. The stored[O,H]weight layout is explained separately. - Code panels are simplified equivalents of the Rust implementation, not drop-in source files.
- The early full-ANE teaching implementation submits model tensor arithmetic through the private AppleNeuralEngine framework. The CPU still handles tokenization, weight preparation, indexing, selection, and control flow. That baseline recomputes history. The newer comparison implementation adds per-request state caching and a resident GPU path; these are separate backends.
- One historical M5 Pro measurement found a 2.85% relative L2 difference between ANE and CPU logits. The first top eight IDs matched, but two-token generation diverged. This is a measured example, not an accuracy bound or performance guarantee. See the validation record.
Chapters 13–16 cover KV and recurrent state, prefill/decode overlap, split and batched FFNs, resident Metal buffers, hybrid vocabulary projection, and speculative verification. Sliders distinguish toy work estimates from recorded hardware measurements. See the November 24 update and evidence boundaries.
The resident backend combines Syrix generation/control with Kapitsa Metal operators, encoding, and loading. The site illustrates that integration; it does not claim those kernels as an independent implementation.
| File | Purpose |
|---|---|
src/content.js |
Bilingual lesson content |
src/scenes.js |
SVG diagrams and interactive controls |
src/advanced-content.js |
New bilingual advanced lessons |
src/advanced.js |
Advanced diagrams, controls, teaching code, and checks |
src/advanced-math.js |
Cache, scheduling, partition, and rounding examples |
src/math.js |
Numerical teaching examples |
src/code.js |
Teaching code and quick checks |
src/app.js |
Navigation, search, language, and progress |
scripts/curriculum-facts.json |
Original editorial fact sheet |
tests/ |
Math, curriculum, and control checks |
The curriculum follows actual learner questions from building a Rust inference implementation. Gemini CLI assisted in rewriting a factual outline into bilingual prose. The final text was reviewed for mathematical conventions, implementation boundaries, and measurement limitations.
- Pi Visualizer: inspired the curriculum, visualization, and explanation layout. This is an independent implementation with original content and diagrams; no source or assets were copied.
- Kapitsa: private ANE execution and device-oriented inference.
- MLX: CPU and GPU array execution.
- Core ML compute units: allowed device combinations.
- Metal threadgroups: grid, threadgroup, and SIMD groups.
- Apple MIL reference: operation definitions.
- Attention Is All You Need: original Transformer attention.
- RoFormer: rotary position embeddings.
MIT — © 2026 chainhelen. Referenced projects retain their own licenses. This repository contains no model weights or copied third-party implementation files.