Home › Neural network training & inference

Neural network training & inference

Autodiff, optimizers, numerics, GPU kernels, multi-GPU parallelism and fast inference.

Architectures

The model families themselves, layer by layer.

Automatic differentiation

How gradients are computed.

Optimizers & schedules

Update rules and learning-rate control.

Numerics & memory

Precision formats and trading compute for memory.

GPU kernels

Making the core ops run at hardware speed.

Multi-GPU parallelism

Splitting training over many devices.

Ring all-reduce

low

Sum a buffer across N workers via reduce-scatter then all-gather around a ring; each link carries 2(N−1)/N of the buffer, which is bandwidth-optimal.

time ≈ 2(N−1)·α + 2(N−1)/N · S/B; per-worker bytes sent 2(N−1)/N · S (bandwidth-optimal, independent of N)

ZeRO and FSDP sharding

low

Data parallelism that shards optimizer state, gradients and weights across ranks and gathers weights just in time; per-GPU model memory drops from 16Ψ to 16Ψ/N.

model-state memory 16Ψ/N bytes (ZeRO-3); communication 3Ψ elements per step vs 2Ψ for plain DDP (1.5x)

Tensor parallelism

low

Split each layer's weight matrices across GPUs (Megatron-style column then row splits) so one layer's math runs on t devices with one all-reduce per block.

per GPU FLOPs and weights ÷ t; 2 all-reduces of b·s·h activations per transformer layer forward, 2 backward

Pipeline parallelism

low

Split the model's layers into stages on different GPUs and stream micro-batches through them; 1F1B scheduling bounds activation memory, the bubble costs (p−1)/m.

bubble fraction (p−1)/(m+p−1) for GPipe and 1F1B, roughly ÷v with v interleaved chunks; point-to-point traffic b·s·h per micro-batch per boundary

context parallelism

Planned.

Collective communication

low

The family of group exchanges (broadcast, reduce, all-gather, reduce-scatter, all-to-all) and the latency-plus-bytes cost model that picks ring, tree or direct algorithms by message size and topology.

all-gather, reduce-scatter, all-to-all (ring/pairwise) (n−1)α + (n−1)/n · S/B; tree variants log₂n · α; broadcast ≥ S/B

embedding table sharding

Planned.

gradient compression

Planned.

weight synchronization

Planned.

distributed checkpointing

Planned.

gpu health checks

Planned.

Inference

Serving trained models fast and cheap.

Weight quantization

low

Store weights as 8/4-bit integers with per-group scales; decode is memory-bound, so 4-bit weights give about 3-4x tokens/s and fit 4x larger models.

quantize O(P) for round-to-nearest (GPTQ about O(d³) per layer); matvec bytes ÷ (16/bits); dequant cost hidden under memory bandwidth

Paged KV cache

low

Store each sequence's attention keys/values in fixed-size blocks mapped through a block table, like virtual memory pages; near-zero fragmentation and copy-on-write sharing.

O(1) block alloc/free; waste < 1 block per sequence; attention does one extra indirection per block of 16 tokens

Continuous batching

low

Schedule LLM inference per iteration, not per request; finished sequences leave and new ones join the running batch every step, which keeps the GPU full.

O(running sequences) scheduler work per step; step time ≈ weight-read floor + per-token compute, so throughput grows almost linearly with batch until compute-bound

Speculative decoding

low

A cheap draft proposes γ tokens, the big model verifies them in one pass, and rejection sampling keeps the target's exact distribution at 2-3x speed.

expected tokens per target pass (1 − α^(γ+1))/(1 − α) for acceptance rate α; speedup bounded by that divided by (1 + γ·c), with c = draft/target cost

Dynamic batching

medium

Queue independent requests and dispatch them as one batch when it is full or the oldest has waited max_delay; bounded extra latency buys throughput.

O(1) per request to enqueue; one backend call per batch; added wait ≤ max_delay

prefill decode disaggregation

Planned.

lora adapters

Planned.

model file formats

Planned.

operator graph partitioning

Planned.

tensor memory planning

Planned.

Training recipes

Medium level: whole training setups assembled from the pieces above.

Decoding & sampling

Turning model outputs into tokens and answers.

Post-training & preference learning

Reward models and RL or preference objectives for tuning LLMs.

reward modeling

Planned.

direct preference optimization

Planned.

grpo

Planned.

verifiable rewards

Planned.

Experiments & hyperparameter search

Tracking runs and searching hyperparameters efficiently.

experiment tracking

Planned.

model registry

Planned.

bayesian optimization

Planned.

tree parzen estimator

Planned.

successive halving hyperband

Planned.

population based training

Planned.