candelabra
candelabra is a small Rust crate for desktop applications that want to run
quantized GGUF models (LLaMA, Qwen, Phi, Gemma, etc.) with
candle-core,
candle-transformers, and
hf-hub.
It focuses on the pieces GUI apps usually need:
- Hugging Face downloads that respect the local
hf-hubcache - tokenizer loading helpers
- optional Metal or CUDA device selection with CPU fallback
- reusable loaded model state
- token streaming with cancellation support
- optional profiled inference telemetry for benchmark-style callers
Current Scope
candelabra natively supports quantized GGUF checkpoints with dynamic architecture detection.
Supported architectures include:
llama/mistral/mixtral/gemma/gemma2phi/phi2phi3qwen2(Qwen 2, Qwen 2.5, QwQ)qwen3qwen3moewhen theqwen3-moefeature is enabled with a Candle build that exposesmodels::quantized_qwen3_moegemma3glm4lfm2(including current LFM2.5 GGUFs that advertiselfm2)smollm3
Qwen3.5 GGUFs are detected explicitly, but are not run through the Qwen3 backend. They use a newer hybrid Gated DeltaNet + attention architecture that requires a dedicated Candle backend before candelabra can support them safely.
That means the crate is a good fit if you want a lightweight Rust API for local
desktop inference on models such as Qwen 2.5 or SmolLM GGUF variants.
It abstracts away the candle_transformers::models paths into a single unified Model block.
Installation
Add the crate to your Cargo.toml:
[]
= "0.2.0"
By default, candelabra builds CPU-only so library consumers can choose their
own Candle backend policy. Enable GPU backends explicitly:
[]
= { = "0.2.0", = ["metal", "accelerate"] } # macOS
[]
= { = "0.2.0", = ["cuda"] } # NVIDIA CUDA
[]
= { = "0.2.0", = ["qwen3-moe"] } # optional Qwen3 MoE GGUF backend
Applications that patch Candle, such as to use CUDA dynamic loading, should keep
the [patch.crates-io] entries in the application workspace root and enable the
matching candelabra feature there.
Quick Start
use ;
use ;
Main API
download_model()downloads a model file through the local Hugging Face cache.download_model_with_progress()anddownload_model_with_channel()emit progress updates suitable for UI progress bars.load_tokenizer_from_repo()downloads and loadstokenizer.json.Model::load()loads a quantized GGUF model onto the best available device, dynamically instantiating the correct Candle architecture based on metadata.Model::architecture()returns the GGUF architecture name reported by the model metadata.Model::reset_state()reloads weights on the selected device to clear backend-owned KV/cache state between isolated runs.run_inference()streams generated tokens through a callback.run_inference_profiled()returnsProfiledInferenceResultwith prompt-processing, decode, first-token, callback, and stop-reason telemetry for benchmarks.run_inference_with_channel()streams generated tokens over a Tokio channel.InferenceConfig::stop_on_eoscontrols whether generation stops when a common EOS token is sampled; it defaults totrue.
Platform Notes
- With the
metalfeature enabled on macOS, the crate prefers Metal and falls back to CPU. - With the
cudafeature enabled on non-macOS platforms, the crate prefers CUDA and falls back to CPU. - Without a GPU backend feature, the crate stays CPU-only.
- The public
device_usedstring is intended to be easy to surface directly in desktop UIs.
License
Licensed under either of these, at your option:
- Apache License, Version 2.0
- MIT license