← Back to Leaderboard
Chuggingface

huggingface/candle

Rust ML SDK for embedding local model inference without a Python runtime

View on GitHub ↗
AI FrameworkQuickstart ↓
Engineering Health (Methodology)
A+ · 88/100
Maintenance Activity
● Updated today
Latest Release
Rolling commits (main)
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption22/25
Release Cadence11/20
License Clarity20/20
Local AIGPU
Total Stars
★ 21,505
24h Growth
+21
7d Growth
+81
Forks
1,906

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

huggingface/candle Star History (2023-06-20 - 2026-12-04) ALL-TIME STAR HISTORY (2023-06 – 2026-12) +21.5k in 1263d · avg +17/day 22.7k 11.4k 0 2023-06-20: ★ 12023-09-09: ★ 7,6202023-11-25: ★ 9,6642024-02-10: ★ 11,4802024-04-27: ★ 12,9462024-07-13: ★ 13,9762024-09-28: ★ 14,8422024-12-14: ★ 15,5952025-03-01: ★ 16,2682025-05-17: ★ 16,8102025-08-02: ★ 17,3932025-10-18: ★ 18,0032026-01-03: ★ 18,7092026-03-21: ★ 19,5312026-06-06: ★ 20,2712026-08-22: ★ 20,8502026-12-04: ★ 21,505 ★ 21.5k 2023-06 2025-03 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

Candle is a Rust ML SDK organized as a Cargo workspace using edition 2021 and resolver 2. candle-core owns Tensor, device selection, and core operators; candle-nn supplies neural-network building blocks; and candle-transformers provides model implementations and utilities. candle-examples/examples/llama/ is a concrete starting point for integrating a model. The matrix-multiplication example shows the execution model: create tensors on a Device, then call matmul; a CUDA-enabled build can select Device::new_cuda(0) instead of Device::Cpu.

The extension point is a custom operator or kernel embedded in the Rust application, not a network protocol. FlashAttention v2 illustrates that boundary. The tree also contains CUDA and Metal kernel directories, a separate FlashAttention v3 directory, and candle-onnx for model evaluation. Those directories are excluded from workspace membership, so their presence does not mean they are built by default. accelerate-src is listed as a workspace dependency for native acceleration.

Key Capabilities & Differentiators

Candle combines a PyTorch-like tensor API and training support with implementations for LLaMA, Gemma, Mamba, and Qwen3 MoE, among others. Quantized paths include LLaMA, Mistral, Mixtral, and Qwen3 MoE. The examples extend beyond text generation: T5 and Marian MT cover text-to-text workloads, Whisper handles speech recognition, and Stable Diffusion covers image generation.

The CPU backend can use optional MKL on x86 or Accelerate on macOS. CUDA supports multi-GPU distribution through NCCL, and selected models can execute in the browser through WebAssembly. Safetensors helpers load and save tensors; ONNX evaluation lives in candle-onnx. Verify the exact checkpoint, dtype, operators, and backend together: a supported model family or file format does not establish that every variant or graph will run on every target.

Trade-offs & Limitations

Candle's main advantage over tch-rs is that a native Candle application need not ship LibTorch or use a Python runtime. That is useful when deploying a Rust binary, but it shifts model integration work onto the application: a PyTorch model without a matching Candle implementation may need porting and operator validation. Burn is worth evaluating if backend choice is the primary requirement. If you need a ready-made HTTP model server, budget for a separate serving layer rather than treating the Candle SDK as one.

The lightweight packaging goal does not remove GPU drivers, native libraries, or model artifacts. Optional MKL and Accelerate can fail at link time when their native dependencies are not linked correctly. End-to-end cold-start performance also depends on storage: under WSL, loading weights from /mnt/c can be materially slower. Benchmark startup, model loading, and inference separately on the target system.

Hardware & Deployment Guide

For a first integration, add candle-core to a Cargo application and validate the CPU path with cargo run. Add the model and tokenizer artifacts separately; package them with the application for offline use if their terms permit it. Gated checkpoints such as LLaMA 2 require accepting the model terms and authenticating to download. The browser path uses the wasm32-unknown-unknown target; the llama2-c example uses Trunk to serve the application and needs model.bin and tokenizer.json.

For NVIDIA builds, align the CUDA toolkit, host compiler, and target GPU. Set CUDA_COMPUTE_CAP explicitly for a Docker build that cannot detect the target GPU. If FlashAttention hits the documented GCC 11 compilation failure, NVCC_CCBIN can select a compatible host compiler. Validate model load time, peak memory, and generation under the intended workload before choosing an instance type. Cargo.toml lists workspace version 0.11.1; no latest GitHub release is listed, so the manifest version alone does not establish release timing or cadence.

Crate boundaries: candle-core owns tensors and devices, candle-nn supplies neural-network building blocks, and candle-transformers houses model code.
Native backends: Optimized CPU execution with optional MKL on x86 or Accelerate on macOS, plus CUDA and NCCL for multi-GPU distribution.
Custom operators: The tree includes candle-kernels, candle-metal-kernels, and separate FlashAttention and FlashAttention v3 directories; FlashAttention v2 is the concrete integration example.
Model coverage: Quantized LLaMA, Mistral, Mixtral, and Qwen3 MoE implementations sit alongside examples for Whisper, Stable Diffusion, and vision models.
Browser execution: candle-wasm-examples/llama2-c targets wasm32-unknown-unknown and uses model.bin and tokenizer.json.
Artifact integration: Safetensors helpers load and save tensors, while the separate candle-onnx crate provides ONNX evaluation.
Best For

Rust teams embedding a supported model into a local tool, application, or inference worker, especially when avoiding Python and LibTorch matters and the team can validate the target backend.

Skip If

You need a turnkey model server, rely on unported PyTorch models or operators, or cannot test the exact checkpoint and backend on production hardware.

Reviewed on 2026-12-04 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

Local AIGPU
cargo run --example quantized --release

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
candle ★21.5k+81RustApache-2.0Rust ML SDK for embedding local model inference without a Python runtime
transformers169.6k+337PythonApache-2.0A PyTorch model-definition SDK for unified inference and training across modalit
tokenizers11.4k+62RustApache-2.0Embeddable Rust tokenization for model-compatible text encoding and decoding
burn16.4k+39RustApache-2.0Rust tensor framework for shared training and inference code across CPU and GPU

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/huggingface/candle.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

huggingface/candle Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about candle

How do I integrate a model into an existing Rust application?

Start with candle-core for tensors and device selection. Add candle-nn for layer building blocks and candle-transformers if it implements your model. Use the matching example to check weight loading, tokenization, and generation. Moving tensors to CUDA with to_device does not guarantee that every operation in the model is supported on that backend.

How much RAM or VRAM should I budget?

There is no single RAM or VRAM requirement. Estimate weight storage from the exact checkpoint and precision, then measure peak memory with your expected context length, batch size, and concurrency. For autoregressive models that use a KV cache, longer contexts and more concurrent sequences increase cache usage. Quantized weights can reduce weight memory, but do not assume that cache and temporary buffers shrink by the same amount.

Can we self-host Candle commercially or redistribute it with model weights?

The Cargo workspace declares MIT OR Apache-2.0, and both license files are present. Review the notice and redistribution obligations for the license you choose and for dependencies you ship. Model terms are separate: check the exact checkpoint's commercial-use and redistribution conditions. For gated LLaMA 2 weights, accepting the model terms and authenticating grants download access; it does not by itself establish redistribution rights.

When should I choose Candle instead of tch-rs or Burn?

Choose Candle when the model has a suitable native Rust implementation and you want to avoid shipping LibTorch. Choose tch-rs when access to Torch from Rust matters more than removing that runtime dependency. Evaluate Burn when choosing among execution backends is a central design requirement. Test the exact model and operations on the intended target before committing to any of them.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining huggingface/candle? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature huggingface/candle on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare