
Opis
Modern AI runs on inference, and inference is a systems problem: gigabytes of weights and KV caches must move through memory hierarchies with minimal latency, thousands of concurrent requests must be scheduled and batched, and the whole stack must stay reliable under load. This book lifts the covers off: you will build a complete LLM inference engine in Rust, from the mathematics of attention to a production-ready HTTP server.Chapter by chapter, you will assemble the engine that powers real serving: implement tokenizers with BPE, build attention with causal masking and FlashAttention-style tiling, design KV caches with PagedAttention-style block management, quantize weights to INT4, INT8, and FP8, and schedule thousands of requests with continuous batching.
You will then make it fast: SIMD vectorization and rayon parallelism on the CPU, custom CUDA kernels on the GPU, and tensor parallelism across multiple GPUs, with every optimization benchmarked against leading frameworks such as vLLM, llama.cpp, and Candle.
Finally, you will ship it: load models from safetensors and GGUF, wrap the engine in an axum server with streaming completions, and deploy with Docker, Kubernetes, metrics, and tracing. The result is an engine within ten percent of llama.cpp's throughput and a mental model of every byte moving through it.