ggml

Dependency-free C and C++ math for running models on CPUs, GPUs, NPUs and in a browser

Tensor library for machine learning

Category
AI models & inference
Audience
Data & ML
Language
C++
Licence
MIT

Updated

ggml is a tensor library for machine learning written in plain C and C++, with backends for laptop CPUs, GPUs, NPUs and WebAssembly in a browser. It is aimed at C and C++ developers who write their own inference code: people embedding a model inside an application, porting one onto an unusual chip, or fitting a quantized model onto hardware that will never host a large Python stack. If you only want to chat with a local model, this is the layer underneath such a tool rather than the tool itself. The project is MIT licensed and has collected roughly 15.8k stars and 1.9k forks on GitHub since 2022, and it was still being pushed to in November 2026.

What it does

The project states its own goal plainly: a simple, portable, efficient tensor library with minimal setup. From the README, that means:

  • A plain C and C++ implementation with no dependencies
  • Cross-platform support for x86, ARM, RISC-V, LoongArch, PowerPC, s390x and WebAssembly
  • SIMD-optimized kernels for x86, ARM and RISC-V
  • Backends for CPU, GPU, NPU and the browser
  • 2-bit to 8-bit integer quantization, plus the MXFP4 and NVFP4 microscaling formats
  • Zero memory allocations during runtime

The video covers the 1.0 release. As the release is described, it prunes the deprecated API and the old mask operations as part of a larger cleanup, and adds YaRN truncation, FP8 support and speed work across backends. On CUDA specifically, that speed work means fused low-bit matrix multiplications on the gate and up layers. Flash attention and mixture-of-experts gains differ by backend, so results are not identical everywhere you run it. These are the project's own descriptions of its work; the materials contain no benchmark numbers, and no independent measurement is quoted here.

How it works

You link ggml into your own program rather than running it as a service. ggml arranges memory up front, which is what the "zero memory allocations during runtime" line refers to, and architecture-specific SIMD kernels, or a separate backend when you build with one, handle the heavy arithmetic. Weights travel in the GGUF file format, which the repository documents in docs/gguf.md.

One organisational detail matters if you plan to contribute: the contributing note asks that changes to the core library, including the CMake build system, be opened as pull requests against llama.cpp instead, because they get more visibility, testing and review there.

Getting started

Nothing here needs an API key, an account or a paid service: the library is MIT licensed, and the only thing you pay for is the hardware you run it on. The fused low-bit matmul speedups do require a CUDA-capable GPU; the CPU and browser builds run fine without one. Beyond naming the supported architectures, the project does not list hardware requirements, so there is no stated minimum RAM or VRAM to quote.

The repository is at github.com/ggml-org/ggml, and installation is a plain clone and CMake build:

git clone https://github.com/ggml-org/ggml
cd ggml
mkdir build && cd build
cmake ..
cmake --build . --config Release -j 8

Tagged releases are published on the repository's GitHub Releases page. For a first read, the repository points to examples/simple, a minimal and fully commented matrix-multiplication example, plus an "Introduction to ggml" write-up hosted on Hugging Face and a tips and tricks wiki page in the llama.cpp repository.

When to use it / when not

The main catch is compatibility, not performance: after the 1.0 update, old RPC peers and the dropped API calls stop working. Anything you already ship against the deprecated API or the old mask operations needs changes, or needs to stay pinned to an earlier tag.

Use it instead of a Python machine-learning stack when you need a self-contained binary with no dependencies on hardware where installing that stack is not realistic, or when you need low-bit quantization and portable kernels under your own control. Do not use it if you want something ready to run out of the box: ggml is a library, and the materials describe no training workflow or high-level Python interface.

Alternatives

The obvious neighbour is llama.cpp, which is where core ggml development is reviewed and which gives you a finished program to run instead of code to link. Reach for llama.cpp when your goal is serving or testing a model, and for ggml when you are building the surrounding software yourself. For research and training, a mainstream Python framework remains the normal choice; nothing in this repository's materials positions it as a replacement for one.

Take ggml seriously if you ship inference inside a product, target hardware outside the usual x86-plus-NVIDIA pairing, or care about exactly how many bits your weights occupy. It is a small, blunt, well-travelled piece of infrastructure with a wide backend list and an active commit history, and 1.0 is a good moment to adopt it as long as you budget time for the API removals. If you are not writing C or C++, you will almost certainly meet ggml through something built on it rather than directly.

More in AI models & inference

All of AI models & inference →