cognisoc / zigllm
The syllabus

Six layers, bottom up.

zigllm is read like a textbook. Each layer depends only on the layers beneath it, so you build real understanding in order — from a flat buffer of floats to a streaming generation loop. Nothing below is a paid course: it is a free, MIT-licensed code-along you follow in the repository and the docs.

Layer 1

Foundation

What you build

A tensor type, an arena/allocator strategy, and memory-mapped file reading.

What you learn

How an n-dimensional array is really just a flat buffer plus shape and stride — and why memory layout is the first thing that governs performance.

Tensors (shape, stride, dtype)Manual memory managementMemory-mapped I/O
Layer 2

Linear algebra

What you build

SIMD matrix-multiply kernels and the K-quant / IQ-quant decode paths.

What you learn

Why matmul dominates the flops, how quantization trades bits for memory bandwidth, and what @Vector buys you over a scalar loop.

SIMD matmulK-quantizationIQ-quantization
Layer 3

Neural primitives

What you build

Activation functions, normalization, and rotary positional encoding.

What you learn

The small, exact operations a transformer repeats thousands of times — SwiGLU, GELU, RMSNorm, and how RoPE rotates query/key vectors by position.

Activations (SwiGLU, GELU)Normalization (RMSNorm)RoPE
Layer 4

Transformers

What you build

Multi-head attention, feed-forward networks, and a full transformer block.

What you learn

How attention scores are computed, scaled, softmaxed and mixed — and how a block wires attention and FFN together with residual connections.

Multi-head attentionFeed-forward networksFull blocks
Layer 5

Models

What you build

18 architecture families, GGUF loading, and tokenization.

What you learn

How real model families differ — where they place norms, how they scale embeddings, what they do with attention — and how to read a pre-trained GGUF file into your own tensors.

18 architecture familiesGGUF loadingTokenization
Layer 6

Inference

What you build

The generation loop, KV caching, streaming, and the full family of samplers.

What you learn

How next-token prediction becomes "generation": autoregression, the KV cache that makes it fast, and every sampler from greedy to Mirostat and grammar-constrained decoding.

Generation & KV cachingStreamingSampling (top-k/p, Mirostat, grammars)

Ready to open the repo?

Set up Zig, run the tests, and start at Layer 1.