repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/layer_norm.rs
candle-nn/tests/layer_norm.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle::{test_utils, Device, Tensor}; use candle_nn::{LayerNorm, Module}; #[test] fn layer_norm() -> Result<()> { let device = &Device::Cpu; let w = Tensor::new(&[3f32], dev...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/sdpa.rs
candle-nn/tests/sdpa.rs
#[cfg(feature = "metal")] mod metal_sdpa_tests { use candle::{DType, Device, Result, Shape, Tensor}; use rand::SeedableRng; use rand_distr::Distribution; use std::ops::{Div, Mul}; fn randn<S: Into<Shape>>( rng: &mut rand::rngs::StdRng, shape: S, dev: &Device, ) -> Result...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/rnn.rs
candle-nn/tests/rnn.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_utils::to_vec2_round, DType, Device, Result, Tensor}; use candle_nn::RNN; /* The following test can be verified against PyTorch using the following snippet. import torch from torch import...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/optim.rs
candle-nn/tests/optim.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::test_utils::{to_vec0_round, to_vec2_round}; use anyhow::Result; use candle::{DType, Device, Tensor, Var}; use candle_nn::{AdamW, Linear, Module, Optimizer, ParamsAdamW, SGD}; #[test] fn sgd_op...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/batch_norm.rs
candle-nn/tests/batch_norm.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle::{test_utils, DType, Device, Tensor}; use candle_nn::{batch_norm, BatchNorm, BatchNormConfig, VarBuilder, VarMap}; /* The test below has been generated using the following Py...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/loss.rs
candle-nn/tests/loss.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::test_utils::to_vec0_round; use candle::{Device, Result, Tensor}; /* Equivalent python code: import torch import torch.nn.functional as F input = torch.tensor([ [ 1.1050, 0.3013, -1.5394, -2...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/group_norm.rs
candle-nn/tests/group_norm.rs
/* Equivalent PyTorch code. import torch from torch.nn.functional import group_norm t = torch.tensor( [[[-0.3034, 0.2726, -0.9659], [-1.1845, -1.3236, 0.0172], [ 1.9507, 1.2554, -0.8625], [ 1.0682, 0.3604, 0.3985], [-0.4957, -0.4461, -0.9721], [ 1.5157, -0....
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/kv_cache.rs
candle-nn/tests/kv_cache.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{Device, Result, Tensor}; #[test] fn kv_cache() -> Result<()> { let mut cache = candle_nn::kv_cache::Cache::new(0, 16); for _ in [0, 1] { assert_eq!(cache.current_seq_len(), 0);...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/ops.rs
candle-nn/tests/ops.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_device, test_utils::to_vec3_round, Device, IndexOp, Result, Tensor}; fn softmax(device: &Device) -> Result<()> { let data = &[[[3f32, 1., 4.], [1., 5., 9.]], [[2., 1., 7.], [8., 2., 8...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/tests/cpu_flash_attn.rs
candle-nn/tests/cpu_flash_attn.rs
use candle::{DType, Device, Result, Tensor}; use candle_nn::cpu_flash_attention::run_flash_attn_cpu; #[test] fn cpu_flash_attn() -> Result<()> { let b = 1; let s = 2; let h = 1; let d = 4; let softmax_scale = 1.0f32 / (d as f32).sqrt(); let q = Tensor::randn(0f32, 1f32, (b, h, s, d), &Device::...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/benches/bench_main.rs
candle-nn/benches/bench_main.rs
mod benchmarks; use criterion::criterion_main; criterion_main!( benchmarks::softmax::benches, benchmarks::layer_norm::benches, benchmarks::conv::benches );
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/benches/benchmarks/layer_norm.rs
candle-nn/benches/benchmarks/layer_norm.rs
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle::{DType, Device, Module, Tensor}; use candle_nn::LayerNorm; use criterion::{criterion_group, Criterion}; use std::hint::black_box; use std::time::Instant; fn run(input: &Tensor, weight: &Tensor, bias: &Tensor) { let _ = LayerNorm::new(weight.clon...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/benches/benchmarks/softmax.rs
candle-nn/benches/benchmarks/softmax.rs
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle::{DType, Device, Tensor}; use candle_nn::ops::softmax_last_dim; use criterion::Throughput; use criterion::{criterion_group, Criterion}; use std::hint::black_box; use std::time::Instant; fn run(input: &Tensor) { let _ = softmax_last_dim(input).unw...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/benches/benchmarks/mod.rs
candle-nn/benches/benchmarks/mod.rs
pub(crate) mod conv; pub(crate) mod layer_norm; pub(crate) mod softmax; use candle::{Device, Result}; pub(crate) trait BenchDevice { fn sync(&self) -> Result<()>; fn bench_name<S: Into<String>>(&self, name: S) -> String; } impl BenchDevice for Device { fn sync(&self) -> Result<()> { match self {...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/benches/benchmarks/conv.rs
candle-nn/benches/benchmarks/conv.rs
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle::{DType, Device, Module, Tensor}; use candle_nn::{Conv2d, Conv2dConfig}; use criterion::{criterion_group, Criterion}; use std::hint::black_box; use std::time::Instant; const B: usize = 1; const C: usize = 1; fn run(input: Tensor, weight: Tensor, bia...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/examples/basic_optimizer.rs
candle-nn/examples/basic_optimizer.rs
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, Device, Result, Tensor}; use candle_nn::{linear, AdamW, Linear, Module, Optimizer, ParamsAdamW, VarBuilder, VarMap}; fn gen_data() -> Result<(Tensor, Tensor)> { // Generate some sam...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-nn/examples/cpu_benchmarks.rs
candle-nn/examples/cpu_benchmarks.rs
/// This example contains some simple benchmarks so that it's easy to run them in perf etc. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::quantized::GgmlType; use candle::{CpuStorage, Device, Layout, Module, Result, Shape, Tensor, D}; use c...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-kernels/build.rs
candle-kernels/build.rs
use std::env; use std::path::PathBuf; fn main() { println!("cargo::rerun-if-changed=build.rs"); println!("cargo::rerun-if-changed=src/compatibility.cuh"); println!("cargo::rerun-if-changed=src/cuda_utils.cuh"); println!("cargo::rerun-if-changed=src/binary_op_macros.cuh"); // Build for PTX let ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-kernels/src/lib.rs
candle-kernels/src/lib.rs
mod ptx { include!(concat!(env!("OUT_DIR"), "/ptx.rs")); } #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Id { Affine, Binary, Cast, Conv, Fill, Indexing, Quantized, Reduce, Sort, Ternary, Unary, } pub const ALL_IDS: [Id; 11] = [ Id::Affine...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-kernels/src/ptx.rs
candle-kernels/src/ptx.rs
pub const AFFINE: &str = include_str!(concat!(env!("OUT_DIR"), "/affine.ptx")); pub const BINARY: &str = include_str!(concat!(env!("OUT_DIR"), "/binary.ptx")); pub const CAST: &str = include_str!(concat!(env!("OUT_DIR"), "/cast.ptx")); pub const CONV: &str = include_str!(concat!(env!("OUT_DIR"), "/conv.ptx")); pub cons...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-kernels/src/ffi.rs
candle-kernels/src/ffi.rs
use core::ffi::c_void; #[allow(dead_code)] extern "C" { // for unquntized models pub fn moe_gemm_wmma( input: *const c_void, // device pointer [size_m, size_k] weights: *const c_void, // device pointer [num_experts, size_n, size_k] sorted_token_ids: *const i32, // device po...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn-build/src/lib.rs
candle-flash-attn-build/src/lib.rs
//! Build utilities for fetching cutlass headers on-demand. //! //! This crate provides a function to fetch NVIDIA's cutlass library headers //! during build time, avoiding the need for git submodules. use anyhow::{Context, Result}; use std::path::PathBuf; use std::process::Command; const CUTLASS_REPO: &str = "https:...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-wasm-tests/src/lib.rs
candle-wasm-tests/src/lib.rs
pub fn add(left: usize, right: usize) -> usize { left + right } #[cfg(test)] mod tests { use super::*; #[test] fn it_works() { let result = add(2, 2); assert_eq!(result, 4); } }
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-wasm-tests/tests/quantized_tests.rs
candle-wasm-tests/tests/quantized_tests.rs
#![allow(unused)] use candle::{ quantized::{self, k_quants, GgmlDType, GgmlType}, test_utils::to_vec2_round, Device, Module, Result, Tensor, }; use wasm_bindgen_test::*; wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test] fn quantized_matmul_neg() -> Result<()> { let cpu = &Device::Cpu;...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-book/src/simplified.rs
candle-book/src/simplified.rs
//! #A simplified example in Rust of training a neural network and then using it based on the Candle Framework by Hugging Face. //! Author: Evgeny Igumnov 2023 igumnovnsk@gmail.com //! This program implements a neural network to predict the winner of the second round of elections based on the results of the first round...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-book/src/lib.rs
candle-book/src/lib.rs
#[cfg(test)] pub mod simplified; #[cfg(test)] mod tests { use anyhow::Result; use candle::{DType, Device, Tensor}; use parquet::file::reader::SerializedFileReader; // NOTE: Waiting on https://github.com/rust-lang/mdBook/pull/1856 #[rustfmt::skip] #[tokio::test] async fn book_hub_1() { // A...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/batcher.rs
candle-datasets/src/batcher.rs
use candle::{Result, Tensor}; pub struct Batcher<I> { inner: I, batch_size: usize, return_last_incomplete_batch: bool, } impl<I> Batcher<I> { fn new(inner: I) -> Self { Self { inner, batch_size: 16, return_last_incomplete_batch: false, } } p...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/lib.rs
candle-datasets/src/lib.rs
//! Datasets & Dataloaders for Candle pub mod batcher; pub mod hub; pub mod nlp; pub mod vision; pub use batcher::Batcher;
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/hub.rs
candle-datasets/src/hub.rs
use hf_hub::{ api::sync::{Api, ApiRepo}, Repo, RepoType, }; use parquet::file::reader::SerializedFileReader; use std::fs::File; /// Re-export of the `FileReader` trait from the `parquet` crate. /// /// This trait provides access to Parquet file metadata and row groups: /// - [`FileReader::metadata`] /// - [`Fi...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/vision/cifar.rs
candle-datasets/src/vision/cifar.rs
//! The CIFAR-10 dataset. //! //! The files can be downloaded from the following page: //! <https://www.cs.toronto.edu/~kriz/cifar.html> //! The binary version of the dataset is used. use crate::vision::Dataset; use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parque...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/vision/mnist.rs
candle-datasets/src/vision/mnist.rs
//! The MNIST hand-written digit dataset. //! //! The files can be obtained from the following link: //! <http://yann.lecun.com/exdb/mnist/> use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parquet::file::reader::{FileReader, SerializedFileReader}; use std::fs::File;...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/vision/mod.rs
candle-datasets/src/vision/mod.rs
use candle::Tensor; pub struct Dataset { pub train_images: Tensor, pub train_labels: Tensor, pub test_images: Tensor, pub test_labels: Tensor, pub labels: usize, } pub mod cifar; pub mod fashion_mnist; pub mod mnist;
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/vision/fashion_mnist.rs
candle-datasets/src/vision/fashion_mnist.rs
//! Zalando Fashion MNIST dataset. //! A slightly more difficult dataset that is drop-in compatible with MNIST. //! //! Taken from here: https://huggingface.co/datasets/zalando-datasets/fashion_mnist use candle::Result; pub fn load() -> Result<crate::vision::Dataset> { crate::vision::mnist::load_mnist_like( ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/nlp/tinystories.rs
candle-datasets/src/nlp/tinystories.rs
//! Helper functions for the tinystories dataset. This uses the pre-tokenized version as generated //! by the tools from https://github.com/karpathy/llama2.c use candle::{Device, Result, Tensor}; pub struct Dataset { valid_tokens: Vec<memmap2::Mmap>, train_tokens: Vec<memmap2::Mmap>, } fn mmap_file(p: &std::p...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-datasets/src/nlp/mod.rs
candle-datasets/src/nlp/mod.rs
pub mod tinystories;
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn/build.rs
candle-flash-attn/build.rs
// Build script to run nvcc and generate the C glue code for launching the flash-attention kernel. // The cuda build time is very long so one can set the CANDLE_FLASH_ATTN_BUILD_DIR environment // variable in order to cache the compiled artifacts and avoid recompiling too often. use anyhow::{Context, Result}; use candl...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn/src/lib.rs
candle-flash-attn/src/lib.rs
mod ffi; use candle::backend::BackendStorage; use candle::cuda_backend::cudarc::driver::DevicePtr; use candle::{CpuStorage, DType, Layout, Result, Shape, Tensor}; use half::{bf16, f16}; pub struct FlashAttn { pub softmax_scale: f32, pub alibi_slopes: Option<Tensor>, pub window_size_left: Option<usize>, ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
true
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn/src/ffi.rs
candle-flash-attn/src/ffi.rs
use core::ffi::{c_int, c_void}; extern "C" { pub(crate) fn run_mha( q_ptr: *const c_void, k_ptr: *const c_void, v_ptr: *const c_void, o_ptr: *const c_void, softmax_lse_ptr: *const c_void, alibi_slopes_ptr: *const c_void, cu_seqlens_q_ptr: *const i32, ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn/tests/flash_attn_tests.rs
candle-flash-attn/tests/flash_attn_tests.rs
use anyhow::Result; use candle::{DType, Device, IndexOp, Tensor, D}; fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> { let b = 10f32.powi(digits); let t = t.to_vec3::<f32>()?; let t = t .iter() .map(|t| { t.iter() .map(|t| t.iter().map(|t| ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/lib.rs
candle-transformers/src/lib.rs
pub mod fused_moe; pub mod generation; pub mod models; pub mod object_detection; pub mod pipelines; pub mod quantized_nn; pub mod quantized_var_builder; pub mod utils;
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/quantized_nn.rs
candle-transformers/src/quantized_nn.rs
//! Utilities for quanitized network layers //! //! This module contains various implementations of standard neural network layers, modules and //! utilities including embedding, linear layers, and various normalization techniques. //! Most implementations provide quantized weights support. use crate::models::with_tra...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/fused_moe.rs
candle-transformers/src/fused_moe.rs
// Adapted from: https://github.com/guoqingbao/vllm.rs/blob/main/src/models/layers/moe.rs use candle::Module; use candle::{quantized::QTensor, DType, Result, Tensor, D}; use candle_nn::{linear_no_bias, moe, Activation, Linear, VarBuilder}; use std::sync::Arc; pub struct MoeCfg { pub hidden_size: usize, pub num...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/object_detection.rs
candle-transformers/src/object_detection.rs
//! Bounding Boxes and Intersection //! //! This module provides functionality for handling bounding boxes and their manipulation, //! particularly in the context of object detection. It includes tools for calculating //! intersection over union (IoU) and non-maximum suppression (NMS). /// A bounding box around an obj...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/utils.rs
candle-transformers/src/utils.rs
//! Apply penalty and repeat_kv use candle::{Result, Tensor}; pub fn apply_repeat_penalty(logits: &Tensor, penalty: f32, context: &[u32]) -> Result<Tensor> { let device = logits.device(); let mut logits = logits.to_dtype(candle::DType::F32)?.to_vec1::<f32>()?; let mut already_seen = std::collections::Hash...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/quantized_var_builder.rs
candle-transformers/src/quantized_var_builder.rs
//! Varbuilder for Loading gguf files //! //! VarBuilder is a utility to store quantized tensors from a [GGUF model file](https://huggingface.co/docs/hub/gguf). //! These tensors can be loaded from disk using `from_gguf` or from an in-memory //! buffer using `from_gguf_buffer`. use candle::quantized::QTensor; use cand...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/mobileclip.rs
candle-transformers/src/models/mobileclip.rs
//! Mobile CLIP model, combining a lightweight vision encoder with a text encoder //! //! A mobile-optimized CLIP implementation that uses: //! - FastViT as the vision encoder //! - OpenCLIP text encoder //! - Projection layers to align the feature spaces //! //! See model details at: //! - [FastViT](https://arxiv.org/...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/with_tracing.rs
candle-transformers/src/models/with_tracing.rs
use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; #[derive(Debug, Clone)] pub struct Embedding { inner: candle_nn::Embedding, span: tracing::Span, } impl Embedding { pub fn new(d1: usize, d2: usize, vb: VarBuilder) -> Result<Self> { let inner = candle_nn::embedding(d1, d2, vb)?; ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/llama.rs
candle-transformers/src/models/llama.rs
//! Llama inference implementation. //! //! See ["LLaMA: Open and Efficient Foundation Language Models"](https://arxiv.org/abs/2302.13971) //! //! Implementation based on Hugging Face's [transformers](https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py) use super::with...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/granitemoehybrid.rs
candle-transformers/src/models/granitemoehybrid.rs
//! GraniteMoeHybrid is a Long Context Transformer Language Model. //! //! A high performance transformer model optimized for efficient processing //! of very long context sequences use super::with_tracing::{linear_no_bias as linear, Linear, RmsNorm}; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/jina_bert.rs
candle-transformers/src/models/jina_bert.rs
//! # JinaBERT inference implementation //! //! Based on implementation from huggingface for Jina BERT and its variants //! //! See: [Jina Embeddings on HuggingFace](https://huggingface.co/jinaai/jina-embeddings-v2-base-en) use super::with_tracing::{linear, linear_no_bias, Embedding, Linear}; use candle::{DType, Devic...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/qwen3.rs
candle-transformers/src/models/qwen3.rs
use crate::{ models::with_tracing::{linear_b, linear_no_bias, Linear, RmsNorm}, utils::repeat_kv, }; use candle::{DType, Device, Module, Result, Tensor}; use candle_nn::{kv_cache::ConcatKvCache, Activation, VarBuilder}; use std::sync::Arc; #[derive(Debug, Clone, PartialEq, serde::Deserialize)] pub struct Confi...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/depth_anything_v2.rs
candle-transformers/src/models/depth_anything_v2.rs
//! Implementation of the Depth Anything model from FAIR. //! //! See: //! - ["Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data"](https://github.com/LiheYoung/Depth-Anything) //! use std::sync::Arc; use candle::D::Minus1; use candle::{Module, Result, Tensor}; use candle_nn::ops::Identity; use candle...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/metavoice.rs
candle-transformers/src/models/metavoice.rs
//! MetaVoice Studio ML Models //! //! See MetaVoice's TTS and voice cloning models: //! - [GitHub](https://github.com/metavoiceio/metavoice-src) //! - [Website](https://studio.metavoice.ai/) use candle::{DType, Device, Error as E, IndexOp, Module, Result, Tensor, D}; use candle_nn::{embedding, linear_b, rms_norm, Emb...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
true
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/resnet.rs
candle-transformers/src/models/resnet.rs
//! # ResNet Implementation //! //! Implementation of ResNet architectures as described in the paper: //! //! ## Reference //! //! [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) //! He et al. (2015) //! //! This paper introduced ResNet, a deep neural network architecture that utilizes ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/bert.rs
candle-transformers/src/models/bert.rs
//! BERT (Bidirectional Encoder Representations from Transformers) //! //! Bert is a general large language model that can be used for various language tasks: //! - Compute sentence embeddings for a prompt. //! - Compute similarities between a set of sentences. //! - [Arxiv](https://arxiv.org/abs/1810.04805) "BERT: Pre...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/vit.rs
candle-transformers/src/models/vit.rs
//! Vision Transformer (ViT) implementation. //! //! Vision Transformer applies transformer architecture to image classification //! by splitting images into patches and processing them as a sequence. //! //! Key characteristics: //! - Image patches as sequence tokens //! - Self-attention between patches //! - Position...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/qwen2_moe.rs
candle-transformers/src/models/qwen2_moe.rs
//! Qwen2 model implementation with Mixture of Experts support. //! //! Qwen2 is a large language model using sparse Mixture of Experts (MoE). //! This implementation provides support for sparsely activated MoE layers. //! //! Key characteristics: //! - Mixture of Experts architecture //! - Sparse expert activation //!...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_qwen3_moe.rs
candle-transformers/src/models/quantized_qwen3_moe.rs
use super::quantized_qwen3::{Gguf, RotaryEmbedding}; use super::with_tracing::QMatMul; use crate::fused_moe::{FusedMoeGGUF, MoeCfg}; use crate::quantized_nn::RmsNorm; use crate::utils::repeat_kv; use candle::quantized::gguf_file; use candle::{DType, Device, Result, Tensor}; use candle_nn::kv_cache::ConcatKvCache; use c...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/glm4_new.rs
candle-transformers/src/models/glm4_new.rs
use crate::models::glm4::EosTokenId; use crate::{ models::with_tracing::{linear_b, linear_no_bias, Linear, RmsNorm}, utils::repeat_kv, }; use candle::{DType, Device, IndexOp, Module, Result, Tensor, D}; use candle_nn::{kv_cache::KvCache, Activation, VarBuilder}; use std::sync::Arc; #[derive(Debug, Clone, serde...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/mobilenetv4.rs
candle-transformers/src/models/mobilenetv4.rs
//! # MobileNet-v4 //! //! MobileNet-v4 inference implementation based on timm. //! //! ## Paper //! //! ["MobileNetV4 - Universal Models for the Mobile Ecosystem"](https://arxiv.org/abs/2404.10518) //! //! ## References //! //! - [PyTorch Implementation](https://github.com/huggingface/pytorch-image-models/blob/main/ti...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
true
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_gemma3.rs
candle-transformers/src/models/quantized_gemma3.rs
//! Gemma 3 model implementation with quantization support. //! //! Gemma 3 is a family of multimodal language models developed by Google. //! This implementation provides quantization for reduced memory usage and faster inference. //! //! Key characteristics: //! - Group-Query Attention (GQA) with specialized key-valu...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/convmixer.rs
candle-transformers/src/models/convmixer.rs
//! ConvMixer implementation. //! //! See "Patches Are All You Need?" by Trockman et al. 2022 //! //! - 📝 [Arxiv](https://arxiv.org/abs/2201.09792) //! - 💻 [GitHub](https://github.com/locuslab/convmixer) //! use candle::Result; use candle_nn::{batch_norm, Conv2dConfig, Module, VarBuilder}; #[allow(clippy::many_singl...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/segformer.rs
candle-transformers/src/models/segformer.rs
//! Segformer model implementation for semantic segmentation and image classification. //! //! Segformer is a transformer-based model designed for vision tasks. It uses a hierarchical //! structure that progressively generates features at different scales. //! //! Key characteristics: //! - Efficient self-attention wit...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/stella_en_v5.rs
candle-transformers/src/models/stella_en_v5.rs
//! Stella v5 model implementation. //! //! Stella is a dense text embedding model optimized for retrieval and similarity tasks. //! This implementation provides support for multiple embedding dimensions. //! //! Key characteristics: //! - Dense text embeddings optimized for similarity search //! - Multiple output dime...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/qwen3_moe.rs
candle-transformers/src/models/qwen3_moe.rs
use crate::{ fused_moe::{FusedMoe, MoeCfg}, models::{ qwen3::{Config as Qwen3Config, Qwen3Attention, Qwen3MLP, Qwen3RotaryEmbedding}, with_tracing::{linear_no_bias, Linear, RmsNorm}, }, }; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{Activation, VarBuilder}; use st...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/dinov2reg4.rs
candle-transformers/src/models/dinov2reg4.rs
//! Implementation of the DINOv2 revision (4 regularization) //! //! The DINOv2-reg4 model is a variant of DINOv2 that adds 4 regularization tokens to the //! original architecture. This implementation is specifically trained for plant species //! classification on the PlantCLEF2024 dataset with 7,806 classes. //! //! ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/chatglm.rs
candle-transformers/src/models/chatglm.rs
//! Implementation of the ChatGLM2/3 models from THUDM. //! //! - 💻 [GitHub](https://github.com/THUDM/ChatGLM3) ChatGLM3: Advancing Multilingual Conversational Language Models with High-Quality Data //! - 💻 [GitHub](https://github.com/THUDM/ChatGLM2-6B) ChatGLM2-6B. //! use crate::models::with_tracing::{linear_b as l...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_t5.rs
candle-transformers/src/models/quantized_t5.rs
//! T5 model implementation with quantization support. //! //! T5 is an encoder-decoder model pre-trained on a multi-task mixture of supervised //! and unsupervised tasks. This implementation provides quantization for reduced //! memory and compute requirements. //! //! Key characteristics: //! - Encoder-decoder archit...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/paligemma.rs
candle-transformers/src/models/paligemma.rs
//! Multimodal multi-purpose model combining Gemma-based language model with SigLIP image understanding //! //! See PaLiGemma details at: //! - [Paper](https://arxiv.org/abs/2402.05257) //! - [Google Blog Post](https://blog.research.google/2024/02/paligemma-scaling-language-image.html) //! //! The model is a multimodal...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/marian.rs
candle-transformers/src/models/marian.rs
//! Marian Neural Machine Translation //! //! See "Marian: Fast Neural Machine Translation in C++" Junczys-Dowmunt et al. 2018 //! - [ACL Anthology](https://aclanthology.org/P18-4020/) //! - [GitHub](https://github.com/marian-nmt/marian) //! use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Ten...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/distilbert.rs
candle-transformers/src/models/distilbert.rs
//! Implementation of DistilBert, a distilled version of BERT. //! //! See: //! - ["DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter"](https://arxiv.org/abs/1910.01108) //! use super::with_tracing::{layer_norm, linear, LayerNorm, Linear}; use candle::{DType, Device, Result, Tensor}; use can...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_llama.rs
candle-transformers/src/models/quantized_llama.rs
//! Quantized llama model implementation. //! //! This provides a quantized implementation of the llama language model architecture. //! The model implements parameter efficient quantization for reduced memory usage //! while maintaining model quality. //! //! Key characteristics: //! - Transformer decoder architecture...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/snac.rs
candle-transformers/src/models/snac.rs
#![allow(unused)] //! Implementation of the Multi-Scale Neural Audio Codec (SNAC) //! //! See: [SNAC](https://github.com/hubertsiuzdak/snac) //! /// Multi-Scale Neural Audio Codec (SNAC) compresses audio into discrete codes at a low bitrate. /// For more information, read the paper: https://arxiv.org/abs/2410.14411 ///...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/rwkv_v5.rs
candle-transformers/src/models/rwkv_v5.rs
//! RWKV v5 model implementation. //! //! The [RWKV model](https://wiki.rwkv.com/) is a recurrent neural network model //! with performance on par with transformer architectures. Several variants are //! available, candle implements the v5 and v6 versions and can be used with //! Eagle 7B([blog post](https://blog.rwkv....
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_stable_lm.rs
candle-transformers/src/models/quantized_stable_lm.rs
//! Module for quantized StableLM implementation. //! //! StableLM is a series of open-source large language models //! optimized for performance and stability. This implementation //! provides quantization support for efficient model deployment. //! //! Key characteristics: //! - RMSNorm for layer normalization //! - ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/yi.rs
candle-transformers/src/models/yi.rs
//! Yi model implementation. //! //! This candle implementation uses a pre-trained Yi decoder-only large language model for inference. //! The model was trained by 01.AI and follows a standard transformer architecture similar to LLaMA. //! //! Original code: //! - 💻 [Yi Model](https://huggingface.co/01-ai/Yi-6B) //! -...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_mistral.rs
candle-transformers/src/models/quantized_mistral.rs
//! Mistral model implementation with quantization support. //! //! Mistral is a large language model optimized for efficiency. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Sliding window attention mechanism //! - Grouped query attention (GQA) //! - RM...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/helium.rs
candle-transformers/src/models/helium.rs
//! Helium inference implementation. //! //! See the model card on Hugging Face's [hub](https://huggingface.co/kmhf/helium-2b). use super::with_tracing::{linear_b as linear, Linear, RmsNorm}; use candle::{DType, Device, Result, Tensor, D}; use candle_nn::{Module, VarBuilder}; use std::sync::Arc; fn default_use_flash_...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/blip.rs
candle-transformers/src/models/blip.rs
//! Based on the BLIP paper from Salesforce Research. //! //! The blip-image-captioning model can generate captions for an input image. //! //! - ⚡ [Interactive Wasm Example](https://huggingface.co/spaces/radames/Candle-BLIP-Image-Captioning) //! - 💻 [GH Link](https://github.com/salesforce/BLIP) //! - 🤗 [HF Link](htt...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/mixtral.rs
candle-transformers/src/models/mixtral.rs
//! Mixtral Model, a sparse mixture of expert model based on the Mistral architecture //! //! See Mixtral model details at: //! - [Hugging Face](https://huggingface.co/docs/transformers/model_doc/mixtral) //! - [Mixtral-8x7B Blog Post](https://mistral.ai/news/mixtral-of-experts/) //! //! The model uses a mixture of exp...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_qwen3.rs
candle-transformers/src/models/quantized_qwen3.rs
//! Qwen3 implementation with quantization support. //! //! Based on the Qwen3 architecture and implemented with quantized weights //! for reduced memory usage and faster inference on compatible hardware. //! //! References: //! - [Qwen3 Models](https://huggingface.co/Qwen/Qwen3-0.6B) (architecture based on official im...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/dinov2.rs
candle-transformers/src/models/dinov2.rs
//! Implementation of the DINOv2 models from Meta Research. //! //! This module implements the DINOv2 vision transformer model from Meta AI Research. //! DINOv2 is a self-supervised learning model that can learn visual features //! without using any labeled data. See: ["DINOv2: Learning Robust Visual Features without S...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/fastvit.rs
candle-transformers/src/models/fastvit.rs
//! # FastViT inference implementation based on timm //! //! ## Description //! See ["FastViT: A Fast Hybrid Vision Transformer using Structural Reparameterization"](https://arxiv.org/pdf/2303.14189) //! //! Implementation based on [timm model](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/f...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/codegeex4_9b.rs
candle-transformers/src/models/codegeex4_9b.rs
//! CodeGeeX4 - A multi-language code generation model //! //! A Pre-Trained Model For Code Generation with Multilingual Evaluations on HumanEval-X" //! //! - 📝 [Arxiv](https://arxiv.org/abs/2303.17568) //! - 💻 [GitHub](https://github.com/THUDM/CodeGeeX) //! use crate::models::with_tracing::{linear_b as linear, Line...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/trocr.rs
candle-transformers/src/models/trocr.rs
//! TrOCR model implementation. //! //! TrOCR is a Transformer-based OCR model that uses a Vision Transformer encoder //! and a BART-like decoder for optical character recognition. //! //! Key characteristics: //! - Vision Transformer encoder for image processing //! - BART-style decoder for text generation //! - Learn...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/dac.rs
candle-transformers/src/models/dac.rs
//! Implementation of the Descript Audio Codec (DAC) model //! //! See: [Descript Audio Codec](https://github.com/descriptinc/descript-audio-codec) //! /// An efficient neural codec for compressing/decompressing audio /// use crate::models::encodec; use candle::{IndexOp, Result, Tensor, D}; use candle_nn::{Conv1d, Conv...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/colpali.rs
candle-transformers/src/models/colpali.rs
//! Colpali Model for text/image similarity scoring. //! //! Colpali combines a vision encoder with an efficient LM for retrieving content. //! use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; use super::paligemma; use candle_nn::{linear, Linear}; pub struct Model { pub model: paligemma::Model, ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_mpt.rs
candle-transformers/src/models/quantized_mpt.rs
//! Quantized MPT model implementation. //! //! MPT (MPT-7B) is a causal transformer model series optimized for code generation. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Multi-Query Grouped Attention (MQA) //! - Support for KV-caching //! - Pre-com...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/mpt.rs
candle-transformers/src/models/mpt.rs
//! Module implementing the MPT (Multi-Purpose Transformer) model //! //! References: //! - [MPT Model used by replit-code-v1_5-3b](https://huggingface.co/replit/replit-code-v1_5-3b/blob/main/modeling_mpt.py) //! - [Configuration](https://huggingface.co/replit/replit-code-v1_5-3b/blob/main/configuration_mpt.py) //! //!...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/modernbert.rs
candle-transformers/src/models/modernbert.rs
//! ModernBERT //! //! ModernBERT is a modernized bidirectional encoder-only Transformer model. //! - [Arxiv](https://arxiv.org/abs/2412.13663) "Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference" //! - Upstream [GitHub repo](https://git...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/recurrent_gemma.rs
candle-transformers/src/models/recurrent_gemma.rs
//! Recurrent Gemma model implementation //! //! Recurrent Gemma is a version of the Gemma language model that incorporates recurrent memory. //! This allows the model to maintain state between predictions and have longer-range memory. //! //! Key characteristics: //! - Real-gated linear recurrent units (RGLRU) //! - 1...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/xlm_roberta.rs
candle-transformers/src/models/xlm_roberta.rs
use crate::models::with_tracing::{linear, Linear}; use candle::{DType, Module, Result, Tensor}; use candle_nn::{ embedding, layer_norm, ops::softmax_last_dim, Activation, Embedding, LayerNorm, VarBuilder, }; #[derive(Debug, Clone, serde::Deserialize)] pub struct Config { pub hidden_size: usize, pub layer_n...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/eva2.rs
candle-transformers/src/models/eva2.rs
//! EVA-2 inference implementation. //! //! EVA-02 is a computer vision model that can be used as an ImageNet classifier. //! The model returns the probability for an image to belong to each of the 1000 //! ImageNet categories. //! //! - [Paper](https://arxiv.org/abs/2303.11331). EVA-02: A Visual Representation for Neo...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/efficientvit.rs
candle-transformers/src/models/efficientvit.rs
//! EfficientViT (MSRA) inference implementation based on timm. //! //! This crate provides an implementation of the EfficientViT model from Microsoft Research Asia //! for efficient image classification. The model uses cascaded group attention modules //! to achieve strong performance while maintaining low memory usag...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/csm.rs
candle-transformers/src/models/csm.rs
//! Implementation of the Conversational Speech Model (CSM) from Sesame //! //! See: [CSM](Conversational Speech Model) //! /// CSM (Conversational Speech Model) is a speech generation model from Sesame that generates RVQ /// audio codes from text and audio inputs. The model architecture employs a Llama backbone and a ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/beit.rs
candle-transformers/src/models/beit.rs
//! Based on the BEIT vision-language model. //! //! See "BEIT: BERT Pre-Training of Image Transformers", Bao et al. 2021 //! - [Arxiv](https://arxiv.org/abs/2106.08254) //! - [GitHub](https://github.com/microsoft/unilm/tree/master/beit) //! use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{laye...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/quantized_qwen2.rs
candle-transformers/src/models/quantized_qwen2.rs
//! Qwen2 model implementation with quantization support. //! //! Qwen2 is a chat-optimized language model that supports 8-bit quantization //! for reduced memory usage and faster inference. //! //! Key characteristics: //! - Group Query Attention (GQA) //! - RMSNorm for layer normalization //! - Rotary positional embe...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/repvgg.rs
candle-transformers/src/models/repvgg.rs
//! RepVGG inference implementation //! //! Key characteristics: //! - Efficient inference architecture through structural reparameterization //! - Single 3x3 conv layer after fusing 3x3 branch, 1x1 branch and identity branch //! - Different configurations including a0-a2, b0-b3 and variants with group convolutions //!...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/mod.rs
candle-transformers/src/models/mod.rs
//! Candle implementations for various deep learning models //! //! This crate provides implementations of popular machine learning models and architectures for different modalities. //! //! - Large language models: [`llama`], [`phi3`], [`mamba`], [`mixtral`], [`bert`], ... //! - Text to text models: [`t5`], ... //! ...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
false
huggingface/candle
https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-transformers/src/models/debertav2.rs
candle-transformers/src/models/debertav2.rs
use std::collections::HashMap; use candle::{bail, Context, DType, Device, Module, Result, Tensor, D}; use candle_nn::{ conv1d, embedding, layer_norm, Conv1d, Conv1dConfig, Embedding, LayerNorm, VarBuilder, }; use serde::{Deserialize, Deserializer}; pub const DTYPE: DType = DType::F32; // NOTE: HiddenAct and Hidd...
rust
Apache-2.0
a4ad7c79666958c38b9afc0e0c3e3499ab8991d8
2026-01-04T15:42:50.663313Z
true