huggingface/candle

Minimalist ML framework for Rust

What it solves

Candle is a minimalist machine learning framework for Rust designed to enable serverless inference and remove Python from production workloads. It addresses the overhead and large binary sizes associated with full frameworks like PyTorch, allowing for the deployment of lightweight, fast binaries.

How it works

It provides a PyTorch-like syntax for tensor operations and model training. Candle supports multiple backends, including an optimized CPU backend (with MKL and Accelerate support), a CUDA backend for GPU acceleration, and WASM for running models directly in the browser. It can load models from various formats including safetensors, npz, ggml, and PyTorch files.

Who it’s for

Developers who want to build and deploy high-performance ML models in Rust, specifically those looking to avoid Python's GIL and the heavy footprint of traditional ML frameworks for serverless or browser-based deployments.

Highlights

  • Broad Model Support: Includes implementations for LLaMA, Mistral, Mixtral, Stable Diffusion, Whisper, and many others.
  • Multi-Backend: Native support for CPU, CUDA, and WebAssembly (WASM).
  • Lightweight: Focused on creating small binaries for efficient serverless deployment.
  • PyTorch-like API: Familiar syntax for those coming from PyTorch, making the transition to Rust easier.
  • Quantization: Supports quantization using llama.cpp types to reduce model size and memory usage.

Related

  • Project
  • Project
  • Project
  • Project
  • Project