Skip to content

Commit

Permalink
Bump the version number to 0.5.1. (huggingface#2155)
Browse files Browse the repository at this point in the history
* Bump the version number to 0.5.1.

* Fix clippy lints for 1.78.

* More clippy fixes.
  • Loading branch information
LaurentMazare authored May 3, 2024
1 parent a09d451 commit 89f53b9
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 80 deletions.
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exclude = [
resolver = "2"

[workspace.package]
version = "0.5.0"
version = "0.5.1"
edition = "2021"
description = "Minimalist ML framework."
repository = "https://github.com/huggingface/candle"
Expand All @@ -33,14 +33,14 @@ ab_glyph = "0.2.23"
accelerate-src = { version = "0.3.2" }
anyhow = { version = "1", features = ["backtrace"] }
byteorder = "1.4.3"
candle = { path = "./candle-core", package = "candle-core", version = "0.5.0" }
candle-datasets = { path = "./candle-datasets", version = "0.5.0" }
candle-flash-attn = { path = "./candle-flash-attn", version = "0.5.0" }
candle-kernels = { path = "./candle-kernels", version = "0.5.0" }
candle-metal-kernels = { path = "./candle-metal-kernels", version = "0.5.0" }
candle-nn = { path = "./candle-nn", version = "0.5.0" }
candle-onnx = { path = "./candle-onnx", version = "0.5.0" }
candle-transformers = { path = "./candle-transformers", version = "0.5.0" }
candle = { path = "./candle-core", package = "candle-core", version = "0.5.1" }
candle-datasets = { path = "./candle-datasets", version = "0.5.1" }
candle-flash-attn = { path = "./candle-flash-attn", version = "0.5.1" }
candle-kernels = { path = "./candle-kernels", version = "0.5.1" }
candle-metal-kernels = { path = "./candle-metal-kernels", version = "0.5.1" }
candle-nn = { path = "./candle-nn", version = "0.5.1" }
candle-onnx = { path = "./candle-onnx", version = "0.5.1" }
candle-transformers = { path = "./candle-transformers", version = "0.5.1" }
clap = { version = "4.2.4", features = ["derive"] }
criterion = { version = "0.5.1", default-features=false }
cudarc = { version = "0.10.0", features = ["f16"] }
Expand Down
2 changes: 2 additions & 0 deletions candle-core/src/cpu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod erf;
pub mod kernels;

#[allow(unused)]
trait Cpu<const ARR: usize> {
type Unit;
type Array;
Expand All @@ -18,6 +19,7 @@ trait Cpu<const ARR: usize> {
unsafe fn vec_store(mem_addr: *mut f32, a: Self::Unit);
}

#[allow(unused)]
trait CpuF16<const ARR: usize> {
type Unit;
type Array;
Expand Down
38 changes: 0 additions & 38 deletions candle-core/src/cuda_backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
impl<'a> Map1Any for FastReduce<'a> {
fn f<T: DeviceRepr + WithDType + ValidAsZeroBits, W: Fn(CudaSlice<T>) -> S>(
Expand Down
1 change: 0 additions & 1 deletion candle-core/src/quantized/gguf_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ pub enum ValueType {
// The value is a UTF-8 non-null-terminated string, with length prepended.
String,
// 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.
Array,
}
Expand Down
4 changes: 2 additions & 2 deletions candle-examples/examples/yolo-v3/darknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Block {

impl Block {
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),
Some(value) => Ok(value),
}
Expand All @@ -28,7 +28,7 @@ pub struct Darknet {

impl Darknet {
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),
Some(value) => Ok(value),
}
Expand Down
4 changes: 2 additions & 2 deletions candle-flash-attn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candle-flash-attn"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

description = "Flash attention layer for the candle ML framework."
Expand All @@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
readme = "README.md"

[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"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion candle-kernels/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candle-kernels"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

description = "CUDA kernels for Candle"
Expand Down
2 changes: 1 addition & 1 deletion candle-metal-kernels/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candle-metal-kernels"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

description = "Metal kernels for Candle"
Expand Down
2 changes: 1 addition & 1 deletion candle-nn/src/var_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl SimpleBackend for VarMap {
}
}

struct SafeTensorWithRouting<'a> {
pub struct SafeTensorWithRouting<'a> {
routing: HashMap<String, usize>,
safetensors: Vec<SafeTensors<'a>>,
}
Expand Down
6 changes: 3 additions & 3 deletions candle-onnx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "candle-onnx"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

description = "ONNX support for Candle"
Expand All @@ -10,8 +10,8 @@ categories = ["science"]
license = "MIT OR Apache-2.0"

[dependencies]
candle = { path = "../candle-core", package = "candle-core", version = "0.5.0" }
candle-nn = { path = "../candle-nn", version = "0.5.0" }
candle = { path = "../candle-core", package = "candle-core", version = "0.5.1" }
candle-nn = { path = "../candle-nn", version = "0.5.1" }
prost = "0.12.1"

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion candle-transformers/src/models/phi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl RotaryEmbedding {
let (xs1, xs2) = (&xs12[0], &xs12[1]);
let c = self.cos.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)?)?;
Tensor::cat(&[&xs_rot, &xs_pass], D::Minus1)
}
Expand Down
21 changes: 0 additions & 21 deletions candle-wasm-examples/whisper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
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 audio;
pub mod languages;
Expand Down

0 comments on commit 89f53b9

Please sign in to comment.