mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 18:48:51 +00:00
Bump the version number to 0.5.1. (#2155)
* Bump the version number to 0.5.1. * Fix clippy lints for 1.78. * More clippy fixes.
This commit is contained in:
18
Cargo.toml
18
Cargo.toml
@ -20,7 +20,7 @@ exclude = [
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Minimalist ML framework."
|
description = "Minimalist ML framework."
|
||||||
repository = "https://github.com/huggingface/candle"
|
repository = "https://github.com/huggingface/candle"
|
||||||
@ -33,14 +33,14 @@ ab_glyph = "0.2.23"
|
|||||||
accelerate-src = { version = "0.3.2" }
|
accelerate-src = { version = "0.3.2" }
|
||||||
anyhow = { version = "1", features = ["backtrace"] }
|
anyhow = { version = "1", features = ["backtrace"] }
|
||||||
byteorder = "1.4.3"
|
byteorder = "1.4.3"
|
||||||
candle = { path = "./candle-core", package = "candle-core", version = "0.5.0" }
|
candle = { path = "./candle-core", package = "candle-core", version = "0.5.1" }
|
||||||
candle-datasets = { path = "./candle-datasets", version = "0.5.0" }
|
candle-datasets = { path = "./candle-datasets", version = "0.5.1" }
|
||||||
candle-flash-attn = { path = "./candle-flash-attn", version = "0.5.0" }
|
candle-flash-attn = { path = "./candle-flash-attn", version = "0.5.1" }
|
||||||
candle-kernels = { path = "./candle-kernels", version = "0.5.0" }
|
candle-kernels = { path = "./candle-kernels", version = "0.5.1" }
|
||||||
candle-metal-kernels = { path = "./candle-metal-kernels", version = "0.5.0" }
|
candle-metal-kernels = { path = "./candle-metal-kernels", version = "0.5.1" }
|
||||||
candle-nn = { path = "./candle-nn", version = "0.5.0" }
|
candle-nn = { path = "./candle-nn", version = "0.5.1" }
|
||||||
candle-onnx = { path = "./candle-onnx", version = "0.5.0" }
|
candle-onnx = { path = "./candle-onnx", version = "0.5.1" }
|
||||||
candle-transformers = { path = "./candle-transformers", version = "0.5.0" }
|
candle-transformers = { path = "./candle-transformers", version = "0.5.1" }
|
||||||
clap = { version = "4.2.4", features = ["derive"] }
|
clap = { version = "4.2.4", features = ["derive"] }
|
||||||
criterion = { version = "0.5.1", default-features=false }
|
criterion = { version = "0.5.1", default-features=false }
|
||||||
cudarc = { version = "0.10.0", features = ["f16"] }
|
cudarc = { version = "0.10.0", features = ["f16"] }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
pub mod erf;
|
pub mod erf;
|
||||||
pub mod kernels;
|
pub mod kernels;
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
trait Cpu<const ARR: usize> {
|
trait Cpu<const ARR: usize> {
|
||||||
type Unit;
|
type Unit;
|
||||||
type Array;
|
type Array;
|
||||||
@ -18,6 +19,7 @@ trait Cpu<const ARR: usize> {
|
|||||||
unsafe fn vec_store(mem_addr: *mut f32, a: Self::Unit);
|
unsafe fn vec_store(mem_addr: *mut f32, a: Self::Unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
trait CpuF16<const ARR: usize> {
|
trait CpuF16<const ARR: usize> {
|
||||||
type Unit;
|
type Unit;
|
||||||
type Array;
|
type Array;
|
||||||
|
@ -250,44 +250,6 @@ impl Map1 for Powf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Sum<'a>(&'a [usize]);
|
|
||||||
impl<'a> Map1 for Sum<'a> {
|
|
||||||
fn f<T: DeviceRepr + WithDType + ValidAsZeroBits>(
|
|
||||||
&self,
|
|
||||||
src: &CudaSlice<T>,
|
|
||||||
dev: &CudaDevice,
|
|
||||||
layout: &Layout,
|
|
||||||
) -> Result<CudaSlice<T>> {
|
|
||||||
let shape = layout.shape();
|
|
||||||
let src_dims = shape.dims();
|
|
||||||
let el = shape.elem_count();
|
|
||||||
let mut dst_el = el;
|
|
||||||
for &sum_dim in self.0.iter() {
|
|
||||||
dst_el /= src_dims[sum_dim];
|
|
||||||
}
|
|
||||||
let mut sum_dims = self.0.to_vec();
|
|
||||||
// Sort the sum_dims as they have to be processed from left to right when converting the
|
|
||||||
// indexes.
|
|
||||||
sum_dims.sort();
|
|
||||||
let sum_dims_l: Vec<usize> = sum_dims.iter().map(|&d| src_dims[d]).collect();
|
|
||||||
let sum_dims_s: Vec<usize> = sum_dims
|
|
||||||
.iter()
|
|
||||||
.map(|&d| src_dims[d + 1..].iter().product::<usize>())
|
|
||||||
.collect();
|
|
||||||
let cfg = LaunchConfig::for_num_elems(el as u32);
|
|
||||||
let ds = dev
|
|
||||||
.htod_copy([src_dims, layout.stride(), &sum_dims_l, &sum_dims_s].concat())
|
|
||||||
.w()?;
|
|
||||||
let src = &src.slice(layout.start_offset()..);
|
|
||||||
let func = dev.get_or_load_func(&kernel_name::<T>("sum"), kernels::REDUCE)?;
|
|
||||||
let out = dev.alloc_zeros::<T>(dst_el).w()?;
|
|
||||||
let params = (el, src_dims.len(), sum_dims.len(), &ds, src, &out);
|
|
||||||
// SAFETY: ffi.
|
|
||||||
unsafe { func.launch(cfg, params) }.w()?;
|
|
||||||
Ok(out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FastReduce<'a>(&'a [usize], ReduceOp);
|
struct FastReduce<'a>(&'a [usize], ReduceOp);
|
||||||
impl<'a> Map1Any for FastReduce<'a> {
|
impl<'a> Map1Any for FastReduce<'a> {
|
||||||
fn f<T: DeviceRepr + WithDType + ValidAsZeroBits, W: Fn(CudaSlice<T>) -> S>(
|
fn f<T: DeviceRepr + WithDType + ValidAsZeroBits, W: Fn(CudaSlice<T>) -> S>(
|
||||||
|
@ -135,7 +135,6 @@ pub enum ValueType {
|
|||||||
// The value is a UTF-8 non-null-terminated string, with length prepended.
|
// The value is a UTF-8 non-null-terminated string, with length prepended.
|
||||||
String,
|
String,
|
||||||
// The value is an array of other values, with the length and type prepended.
|
// The value is an array of other values, with the length and type prepended.
|
||||||
///
|
|
||||||
// Arrays can be nested, and the length of the array is the number of elements in the array, not the number of bytes.
|
// Arrays can be nested, and the length of the array is the number of elements in the array, not the number of bytes.
|
||||||
Array,
|
Array,
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ struct Block {
|
|||||||
|
|
||||||
impl Block {
|
impl Block {
|
||||||
fn get(&self, key: &str) -> Result<&str> {
|
fn get(&self, key: &str) -> Result<&str> {
|
||||||
match self.parameters.get(&key.to_string()) {
|
match self.parameters.get(key) {
|
||||||
None => candle::bail!("cannot find {} in {}", key, self.block_type),
|
None => candle::bail!("cannot find {} in {}", key, self.block_type),
|
||||||
Some(value) => Ok(value),
|
Some(value) => Ok(value),
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ pub struct Darknet {
|
|||||||
|
|
||||||
impl Darknet {
|
impl Darknet {
|
||||||
fn get(&self, key: &str) -> Result<&str> {
|
fn get(&self, key: &str) -> Result<&str> {
|
||||||
match self.parameters.get(&key.to_string()) {
|
match self.parameters.get(key) {
|
||||||
None => candle::bail!("cannot find {} in net parameters", key),
|
None => candle::bail!("cannot find {} in net parameters", key),
|
||||||
Some(value) => Ok(value),
|
Some(value) => Ok(value),
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "candle-flash-attn"
|
name = "candle-flash-attn"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
description = "Flash attention layer for the candle ML framework."
|
description = "Flash attention layer for the candle ML framework."
|
||||||
@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
candle = { path = "../candle-core", features = ["cuda"], package = "candle-core", version = "0.5.0" }
|
candle = { path = "../candle-core", features = ["cuda"], package = "candle-core", version = "0.5.1" }
|
||||||
half = { version = "2.3.1", features = ["num-traits"] }
|
half = { version = "2.3.1", features = ["num-traits"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "candle-kernels"
|
name = "candle-kernels"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
description = "CUDA kernels for Candle"
|
description = "CUDA kernels for Candle"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "candle-metal-kernels"
|
name = "candle-metal-kernels"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
description = "Metal kernels for Candle"
|
description = "Metal kernels for Candle"
|
||||||
|
@ -264,7 +264,7 @@ impl SimpleBackend for VarMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SafeTensorWithRouting<'a> {
|
pub struct SafeTensorWithRouting<'a> {
|
||||||
routing: HashMap<String, usize>,
|
routing: HashMap<String, usize>,
|
||||||
safetensors: Vec<SafeTensors<'a>>,
|
safetensors: Vec<SafeTensors<'a>>,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "candle-onnx"
|
name = "candle-onnx"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
description = "ONNX support for Candle"
|
description = "ONNX support for Candle"
|
||||||
@ -10,8 +10,8 @@ categories = ["science"]
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
candle = { path = "../candle-core", package = "candle-core", version = "0.5.0" }
|
candle = { path = "../candle-core", package = "candle-core", version = "0.5.1" }
|
||||||
candle-nn = { path = "../candle-nn", version = "0.5.0" }
|
candle-nn = { path = "../candle-nn", version = "0.5.1" }
|
||||||
prost = "0.12.1"
|
prost = "0.12.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -72,7 +72,7 @@ impl RotaryEmbedding {
|
|||||||
let (xs1, xs2) = (&xs12[0], &xs12[1]);
|
let (xs1, xs2) = (&xs12[0], &xs12[1]);
|
||||||
let c = self.cos.narrow(0, seqlen_offset, seq_len)?;
|
let c = self.cos.narrow(0, seqlen_offset, seq_len)?;
|
||||||
let s = self.sin.narrow(0, seqlen_offset, seq_len)?;
|
let s = self.sin.narrow(0, seqlen_offset, seq_len)?;
|
||||||
let rotate_half = Tensor::cat(&[&xs2.neg()?, &xs1], D::Minus1)?;
|
let rotate_half = Tensor::cat(&[&xs2.neg()?, xs1], D::Minus1)?;
|
||||||
let xs_rot = (xs_rot.broadcast_mul(&c)? + rotate_half.broadcast_mul(&s)?)?;
|
let xs_rot = (xs_rot.broadcast_mul(&c)? + rotate_half.broadcast_mul(&s)?)?;
|
||||||
Tensor::cat(&[&xs_rot, &xs_pass], D::Minus1)
|
Tensor::cat(&[&xs_rot, &xs_pass], D::Minus1)
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,5 @@
|
|||||||
pub const WITH_TIMER: bool = true;
|
pub const WITH_TIMER: bool = true;
|
||||||
|
|
||||||
struct Timer {
|
|
||||||
label: &'static str,
|
|
||||||
}
|
|
||||||
|
|
||||||
// impl Timer {
|
|
||||||
// fn new(label: &'static str) -> Self {
|
|
||||||
// if WITH_TIMER {
|
|
||||||
// web_sys::console::time_with_label(label);
|
|
||||||
// }
|
|
||||||
// Self { label }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
impl Drop for Timer {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
if WITH_TIMER {
|
|
||||||
web_sys::console::time_end_with_label(self.label)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod audio;
|
mod audio;
|
||||||
pub mod languages;
|
pub mod languages;
|
||||||
|
Reference in New Issue
Block a user