Introduction to ggml
ggml is a minimal C/C++ tensor library focused on Transformer inference that underpins llama.cpp, whisper.cpp, ollama and LM Studio. It offers a sub-1MB binary, easy compilation with only GCC or Clang, quantized tensors and broad hardware support. The tradeoffs are uneven operation coverage across backends, a steep low-level learning curve and frequent breaking changes. A walkthrough explains its core abstractions (context, computation graph, backend, buffer types, graph allocator, scheduler) and builds a matrix-multiplication example twice: once with tensor data held in a ggml_context, and once with a CPU/CUDA backend, device buffers and graph allocation.
Related posts
- Transformers now runs llama.cpp quants
Hugging Face mediumAdeptHugging Face transformers can now load GGUF (llama.cpp) quantized checkpoints via `from_pretrained(..., gguf_file=...)` and serve them through `transformers serve` with an OpenAI-compatible API. Weights stay packed on Apple Silicon, and ggml's Metal kernels are reused via the `kernels` library for quantized matmul, fused RMSNorm, flash attention, gated delta nets and MoE top-k routing. Two `generate` changes, dropping all-ones padding masks and deferring the stopping check asynchronously, cut CPU-GPU synchronization for all models. Benchmarks on an M2 Max show throughput close to llama-bench for Qwen3.5 dense and MoE checkpoints, though llama.cpp remains the recommended engine for pure local inference. The initial packed path is MPS-only, and padded batching is still slower.
- Native-speed vLLM transformers modeling backend
Hugging Face hardMasterThe transformers modeling backend in vLLM now matches or beats vLLM's hand-written native implementations in throughput. Benchmarks covered Qwen3-4B on one GPU, Qwen3-32B with tensor parallelism, and Qwen3-235B FP8 MoE with data and expert parallelism on 8×H100. The backend uses torch.fx static analysis to find known patterns, then rewrites the model source via AST to swap in fused vLLM kernels such as QKVParallelLinear, MergedColumnParallelLinear and expert-parallel MoE ops. It also infers TP/PP plans while staying compatible with torch.compile and CUDA Graphs. Any compliant transformers model gets this with `--model-impl transformers`, except linear-attention models and custom Hub-code models.
- Tricks from OpenAI gpt-oss YOU 🫵 can use with transformers
Hugging Face hardMasterHugging Face upgraded transformers to support OpenAI's gpt-oss models, and most of the new features carry over to other models. These include pre-built kernels downloaded from the Hub (Liger RMSNorm, MegaBlocks MoE, Flash Attention 3 with attention sinks), native MXFP4 4-bit quantization via Triton kernels, tensor and expert parallelism, dynamic sliding window caching, continuous batching with paged attention, and faster loading. MXFP4 stores E2M1 values in 32-element blocks with shared scales. That lets gpt-oss-20B run in about 16 GB of VRAM and 120B in about 80 GB, versus roughly 4× the memory in the bf16 fallback. Benchmarks show the custom and MXFP4 kernels pay off mainly at larger batch sizes.
- Hugging Face on AMD Instinct MI300 GPU
Hugging Face easyNoviceHugging Face's transformers and text-generation-inference (TGI) now run on AMD Instinct MI300X GPUs with no code changes, backed by a Kubernetes-scheduled CI pipeline that runs tens of thousands of unit tests on MI250 and MI300 hardware. TGI optimizations for MI300 include Flash Attention v2, Paged Attention, GPTQ/AWQ kernels, fused kernels, and PyTorch's ROCm TunableOp. TunableOp tunes GEMMs during server warmup and gives an 8-10% decode latency gain on small inputs. On Llama 3 70B, MI300X on Azure delivers 2-3x faster time to first token and 2x faster decoding than MI250, and roughly 2x faster LoRA fine-tuning. Its 192 GB HBM3 also fits the full ~140 GB fp16 model on a single GPU.
- How We Built TLX: A Hardware-Native GPU Compiler for Production ML at Scale
Meta Engineering hardMasterTriton Low-Level Extensions (TLX) add explicit warp-group, synchronization, memory and cluster-level orchestration to Triton, so engineers can use Hopper and Blackwell features such as TMA, TMEM, mbarriers and paired-CTA execution without dropping to CUDA. Meta frames the design as a "Multiple Instructions, Multiple Warps" (MIMW) model that sits between CUDA's thread-level SIMT and Triton's block-level SIMB. Triton tensor ops still describe the computation, while TLX constructs describe producer/consumer/epilogue warp-group pipelines. Layouts are inferred by default, which makes kernel fusion much easier, and TLX already runs production RecSys training, RecSys inference and LLM pretraining workloads on NVIDIA and AMD GPUs.