From 9398d8206d4fe2c587a009cc417a034cd2e4b4c3 Mon Sep 17 00:00:00 2001 From: michaelfeil Date: Wed, 17 Dec 2025 21:00:28 +0000 Subject: [PATCH] clippy fix --- backends/candle/src/layers/mod.rs | 4 ++-- backends/candle/src/models/qwen2.rs | 1 - backends/candle/tests/common.rs | 4 ++-- backends/candle/tests/test_bert.rs | 12 +++--------- backends/candle/tests/test_dense.rs | 2 +- backends/candle/tests/test_gte.rs | 4 +--- backends/candle/tests/test_jina.rs | 4 +--- backends/candle/tests/test_modernbert.rs | 8 ++------ 8 files changed, 12 insertions(+), 27 deletions(-) diff --git a/backends/candle/src/layers/mod.rs b/backends/candle/src/layers/mod.rs index 945fc54f1..1849d31b5 100644 --- a/backends/candle/src/layers/mod.rs +++ b/backends/candle/src/layers/mod.rs @@ -8,10 +8,10 @@ mod rms_norm; mod rotary; pub use cublaslt::get_cublas_lt_wrapper; +#[allow(unused_imports)] +pub use index_select::index_select; pub use layer_norm::{LayerNorm, LayerNormNoBias}; pub use linear::{HiddenAct, Linear}; #[allow(unused_imports)] pub use rms_norm::RMSNorm; -#[allow(unused_imports)] -pub use index_select::index_select; pub use rotary::{apply_rotary, get_cos_sin, get_inv_freqs, RopeScaling}; diff --git a/backends/candle/src/models/qwen2.rs b/backends/candle/src/models/qwen2.rs index f7855cd96..10cbb76ec 100644 --- a/backends/candle/src/models/qwen2.rs +++ b/backends/candle/src/models/qwen2.rs @@ -1,6 +1,5 @@ use crate::layers::HiddenAct; use serde::Deserialize; -use tracing; fn default_is_causal() -> bool { tracing::warn!("is_causal not set in Qwen2Config, defaulting to true. e.g. Alibaba-NLP/gte-Qwen2-1.5B-instruct/ was trained with causal=False attention, but jinaai/jina-code-embeddings-0.5b with causal=True. Please set this field explicitly in the huggingface repo to avoid this warning."); diff --git a/backends/candle/tests/common.rs b/backends/candle/tests/common.rs index 896e0f65b..b6b483fd4 100644 --- a/backends/candle/tests/common.rs +++ b/backends/candle/tests/common.rs @@ -85,7 +85,7 @@ impl Deref for SnapshotEmbeddings { impl From>> for SnapshotEmbeddings { fn from(value: Vec>) -> Self { - Self(value.into_iter().map(|v| SnapEmbedding(v)).collect()) + Self(value.into_iter().map(SnapEmbedding).collect()) } } @@ -181,7 +181,7 @@ pub fn download_artifacts( } _ => { for path in &paths { - download_dense_module(&api_repo, &path)?; + download_dense_module(&api_repo, path)?; } Some(paths) } diff --git a/backends/candle/tests/test_bert.rs b/backends/candle/tests/test_bert.rs index c18479e4b..2497e5a34 100644 --- a/backends/candle/tests/test_bert.rs +++ b/backends/candle/tests/test_bert.rs @@ -166,9 +166,7 @@ fn test_emotions() -> Result<()> { let matcher = relative_matcher(); let predictions: Vec> = backend - .predict(input_batch)? - .into_iter() - .map(|(_, v)| v) + .predict(input_batch)?.into_values() .collect(); let predictions_batch = SnapshotScores::from(predictions); insta::assert_yaml_snapshot!("emotions_batch", predictions_batch, &matcher); @@ -180,9 +178,7 @@ fn test_emotions() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions_single = SnapshotScores::from(predictions); @@ -222,9 +218,7 @@ fn test_bert_classification() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions_single = SnapshotScores::from(predictions); diff --git a/backends/candle/tests/test_dense.rs b/backends/candle/tests/test_dense.rs index b523708d8..35ff2e318 100644 --- a/backends/candle/tests/test_dense.rs +++ b/backends/candle/tests/test_dense.rs @@ -65,7 +65,7 @@ fn test_stella_en_400m_v5_dense_768() -> Result<()> { let (model_root, dense_paths) = download_artifacts( "dunzhang/stella_en_400M_v5", None, - Some("2_Dense_768".into()), + Some("2_Dense_768"), )?; let tokenizer = load_tokenizer(&model_root)?; diff --git a/backends/candle/tests/test_gte.rs b/backends/candle/tests/test_gte.rs index ccfad4303..66429afef 100644 --- a/backends/candle/tests/test_gte.rs +++ b/backends/candle/tests/test_gte.rs @@ -165,9 +165,7 @@ fn test_gte_classification() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions_single = SnapshotScores::from(predictions); diff --git a/backends/candle/tests/test_jina.rs b/backends/candle/tests/test_jina.rs index 548c51cac..af63041e0 100644 --- a/backends/candle/tests/test_jina.rs +++ b/backends/candle/tests/test_jina.rs @@ -71,9 +71,7 @@ fn test_jina_rerank() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions = SnapshotScores::from(predictions); diff --git a/backends/candle/tests/test_modernbert.rs b/backends/candle/tests/test_modernbert.rs index 77f05aef3..14c65f37d 100644 --- a/backends/candle/tests/test_modernbert.rs +++ b/backends/candle/tests/test_modernbert.rs @@ -195,9 +195,7 @@ fn test_modernbert_classification() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions_single = SnapshotScores::from(predictions); @@ -234,9 +232,7 @@ fn test_modernbert_classification_mean_pooling() -> Result<()> { ); let predictions: Vec> = backend - .predict(input_single)? - .into_iter() - .map(|(_, v)| v) + .predict(input_single)?.into_values() .collect(); let predictions_single = SnapshotScores::from(predictions);