cd /news/large-language-models/learn-llm-inference-system-on-apple-… Β· home β€Ί topics β€Ί large-language-models β€Ί article
[ARTICLE Β· art-160854] src=github.com β†— pub= topic=large-language-models verified=true sentiment=↑ positive

Learn LLM inference system on Apple Silicon

Systems engineer Chi published tiny-llm, a four-week hands-on course that teaches LLM inference end to end on Apple Silicon by having students implement a Qwen3-4B serving stack in Python, C++, or Metal on MLX arrays rather than calling optimized MLX operations. The course runs from matmul-to-text in Week 1 through KV-cache and quantized-matvec optimizations in Week 2, continuous batching and paged KV in a "mini vLLM" in Week 3, and a bounded coding agent in Week 4, with Days 1 through 9 of Week 4 currently available. The book is published at skyzh.github.io/tiny-llm, and Qwen3-4B was chosen because its grouped-query attention, QK normalization, BF16 activations and 4-bit weights expose real weight-bandwidth, attention and cache costs while remaining iterable on one machine without a CUDA GPU.

read6 min views1 publishedOct 30, 2026
Learn LLM inference system on Apple Silicon
Image: Michielbdejong (auto-discovered)

tiny-llm is a hands-on course for systems engineers who want to understand LLM inference end to end. You can think of it as an LLM-serving counterpart to CMU's Needle project: build the path that loads a Qwen3 model, turns tokens into logits, and generates text.

The course begins with array and matrix operations, then introduces kernels and serving machinery as the running model needs them. Keeping the implementation small enough to read end to end makes it possible to connect the equations to memory traffic, kernel occupancy, KV-cache growth, batching, and request scheduling.

The course is built on MLX arrays and the MLX extension runtime, without using high-level neural-network layers. When a chapter teaches an operator, your solution implements that operator in Python, C++, or Metal rather than calling the corresponding optimized MLX operation. MLX remains the correctness oracle and performance baseline.

The course follows a four-week learning path:

  • Week 1: From Matmul to Text. Build a Qwen3 model directly frommlx.core array operations: attention, RoPE, GQA, RMSNorm, the MLP, sampling, and the autoregressive loop.
  • Week 2: A Faster Single Request. Day 1 addskv-cache and request-boundedcapacity-cache ; Day 2 keeps W4 projection weights packed through thequantized-matvec checkpoint. Day 3 adds SIMD matrix prefill atsimd-matmul . Day 4 adds cumulative RMSNorm, RoPE, and SwiGLU checkpoints. Day 5 addstiled-prefill and runs the completedselected model.
  • Week 3: Build a Mini vLLM. Introduce continuous batching and chunked admission, then make paged KV the canonical serving layout. Decode attention and FlashAttention learn to read pages directly so the scheduler does not rebuild dense history on every step.
  • Week 4: Build a Coding Agent. Start with a bounded, validated agent loop, then connect it to a small workspace. The course is publishing one reviewed checkpoint at a time; Days 1 through 9 now cover inspection, approved edits, one validation command, simple effect receipts, and one visible checkpoint-and-resume boundary, receipt-backed context compaction, and one visible inspect-and-steer , and deterministic evaluation of observable outcomes, then tokenizer/KV-prefix reuse for two isolated steered branches and one explicit evidence-backed selection, followed by bounded, range-retrievable evidence for oversized tool results.

Apple silicon provides a practical local environment with one shared memory space and direct access to Metal kernels. Students can inspect the complete path on one machine instead of depending on an expensive CUDA GPU setup.

Qwen3-4B is large enough to expose real weight-bandwidth, attention, and cache costs, but small enough to iterate on locally. Its grouped-query attention, QK normalization, BF16 activations, and 4-bit weights also keep the exercises close to current model-serving work.

The book is published at skyzh.github.io/tiny-llm. Begin with the environment setup, or verify an existing checkout with:

pdm install -v
pdm run check-installation
pdm run test-refsol -- -- -k week_1

The tiny_llm package is where students implement the exercises. tiny_llm_ref contains the reference solution used by the tests and benchmark appendix. The book summary lists the chapter order; implementation, test, and publication readiness is tracked below.

The table tracks implementation (Code), tests ( Test), rendered chapters ( Doc), and Chi's review of learner-facing material ( Audit). Week 4 is publishing one reviewed day at a time; Days 1 through 9 are currently available to learners. The Audit column reflects Chi's personal editorial pass on the published course content and is independent of code/test/doc readiness.

Day 3 can send file contents to the model, modify files after approval, and run one exact configured command. Use a disposable workspace without secrets and read the Week 4 overview before running the loop. Day 4 checkpoints a complete tool-observation boundary with the scripted model's fake cache metadata, then restores a fresh model without replaying the completed edit or command. Day 5 compacts older completed effects in the model-visible transcript while their exact receipts retain the full action, result, and changed artifacts. Day 6 inspects one complete-observation checkpoint, appends one visible operator instruction, and resumes a fresh model without replaying the completed effect. Day 7 evaluates one completed run from declared final, file, result, and receipt facts without grading hidden reasoning or exact transcript shape. Day 8 reuses one real tokenizer/KV checkpoint for two differently steered, effect-isolated continuations, evaluates both with Day 7's harness, and makes one explicit passing selection without pretending completed effects were rewound. Day 9 stores exact oversized tool-result bytes outside the model prompt, shows a bounded identity/digest/head-tail observation, and lets the model retrieve one explicit byte range through the existing loop.

Week + Chapter Topic Code Test Doc Audit
1.1 Attention βœ… βœ… βœ… βœ…
1.2 RoPE βœ… βœ… βœ… βœ…
1.3 Grouped Query Attention βœ… βœ… βœ… βœ…
1.4 RMSNorm and MLP βœ… βœ… βœ… βœ…
1.5 Load the Model βœ… βœ… βœ… βœ…
1.6 Generate Responses (aka Decoding) βœ… βœ… βœ… βœ…
1.7 Sampling βœ… βœ… βœ… βœ…
2.1 Cache and Measure ( kv-cache ,capacity-cache ) 🚧 🚧 βœ… 🚧
2.2 Keep W4 Packed ( quantized-matvec ) 🚧 🚧 βœ… 🚧
2.3 SIMD Matrix Prefill ( simd-matmul ) 🚧 🚧 βœ… 🚧
2.4 Fused Model Primitives ( rmsnorm ,rope ,swiglu ) 🚧 🚧 βœ… 🚧
2.5 Tiled Dense Prefill Attention ( tiled-prefill ,selected ) 🚧 🚧 βœ… 🚧
3.1 Continuous Batching βœ… βœ… βœ… 🚧
3.2 Chunked Prefill βœ… βœ… βœ… 🚧
3.3 Paged KV Cache βœ… βœ… βœ… 🚧
3.4 Direct Paged Attention βœ… βœ… βœ… 🚧
3.5 Paged FlashAttention βœ… βœ… βœ… 🚧
3.6 (optional) MoE (Mixture of Experts) βœ… βœ… βœ… 🚧
3.7 (optional) Speculative Decoding βœ… βœ… βœ… 🚧
4.1 Validated Agent Loop βœ… βœ… βœ… 🚧
4.2 Inspect a Workspace βœ… βœ… βœ… 🚧
4.3 Edit, Validate, and Record βœ… βœ… βœ… 🚧
4.4 Checkpoint and Resume βœ… βœ… βœ… 🚧
4.5 Compact Completed Work βœ… βœ… βœ… 🚧
4.6 Inspect and Steer a d Agent βœ… βœ… βœ… 🚧
4.7 Evaluate Observable Outcomes βœ… βœ… βœ… 🚧
4.8 Fork, Steer, and Select βœ… βœ… βœ… 🚧
4.9 Bound Tool Evidence βœ… βœ… βœ… 🚧

Earlier Week 2 chapter URLs not reused by active Days 1–5 remain available as historical material. The former Day 4 address now serves the active fused-primitives lesson. Those historical pages describe an earlier test and checkpoint order, separate from the current Day 1 β†’ Day 2 β†’ Day 3 β†’ Day 4 β†’ Day 5 route.

Other topics not covered include quantized or compressed KV caches, cross-request prefix caching, fine-tuning, and long-context techniques.

Join skyzh's Discord server to study with the tiny-llm community.

── more in #large-language-models 4 stories Β· sorted by recency
── more on @tiny-llm 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/learn-llm-inference-…] indexed:0 read:6min 2026-10-30 Β· β€”