Candle
A minimalist ML framework for Rust: PyTorch-like ergonomics with CPU, CUDA, Metal, and WASM backends.
About
Candle is Hugging Face's machine-learning framework for Rust, built for people who want native performance without leaving a systems language. The API deliberately mirrors PyTorch (tensors, autograd, nn modules, optimizers), and it ships backends for CPU (MKL/Accelerate), CUDA, and Metal, plus WebGPU and WASM targets, so the same code can run on a server GPU, a Mac, or in the browser.
The examples directory is the real showcase: LLaMA, Mistral, Mixtral, Qwen, and Phi running as pure-Rust inference, plus Whisper for speech, Stable Diffusion for images, and Segment Anything for vision, all without a Python runtime. At 21,100+ stars and Apache-2.0 it is the default answer for shipping ML in Rust. The trade-off is ecosystem size: you get the core right, but the library of prebuilt models and training recipes is a fraction of PyTorch's, and CUDA builds still need the usual toolchain care.
What it can do
- PyTorch-like API in pure Rust: tensors, autograd, nn, optimizers
- Backends: CPU (MKL/Accelerate), CUDA, Metal, plus WebGPU and WASM targets
- Example zoo: LLaMA, Mistral, Mixtral, Qwen, Phi, Whisper, Stable Diffusion, SAM
- No Python runtime needed for deployment
- Serde-based weight loading from safetensors and HF Hub formats
- Apache-2.0, maintained by Hugging Face
Setup
- Install Rust (rustup) and, for GPU builds, the CUDA toolkit with the right compute capability.
- Add the crates:
cargo add candle-core candle-nn(enable features likecuda,metal,mkl, oracceleratefor your target). - Clone the repo and run an example:
cargo run --example llama --release -- --model-id ...(see candle-examples). - For WASM, add the wasm32 target and build with the documented flags in the README.
Prerequisites
Rust toolchain; for CUDA builds, the CUDA toolkit and matching GPU compute capability; model weights from the Hugging Face Hub.
Use cases
Works with
Trust score — 9/10
Scored 9/10 (verified tier, metrics-v1). Evidence: 21,172 GitHub stars (GitHub API), Apache-2.0, pushed Oct 14 2026; the README documents the backend matrix, the example zoo (LLMs, Whisper, SD, SAM), and the WASM path; docs.rs corroborates the crate API. Strengths: the standard Rust ML framework, Hugging Face maintained, genuinely multi-backend including WASM. Docked for: (1) smaller model/training ecosystem than PyTorch; (2) CUDA builds need toolchain care. License: Apache-2.0.
★ 21,172 GitHub stars
How the trust score is built
Full methodology →- Adoption · stars/downloads, log-scaled vs peers
- 8.0/10
- Maintenance · recency, releases, issue load
- 10.0/10
- Openness · license + docs
- 10.0/10
- Manual review · sanity read + red-flag check
- 9.0/10
- · Adoption 8: starScore from 21,172 stars on huggingface/candle (log scale vs 298k peer max)
- · Maintenance 10: pushed 2026-10-14 (recency 10); Hugging Face maintained
- · Openness 10: Apache-2.0 (0.7*10) + docs.rs and example zoo verified (0.3*10)
- · Manual 9: the standard Rust ML framework corroborated by backend matrix and examples; docked only for smaller model ecosystem vs PyTorch
Sources
Every fact above was checked against these sources. Where a claim comes from the provider and couldn't be independently verified, the text says so.