Skip to content

Commit bedb2e5

Browse files
authored
Add CPU support for Qwen3-Embedding models (#632)
1 parent 18b8367 commit bedb2e5

File tree

6 files changed

+4740
-7
lines changed

6 files changed

+4740
-7
lines changed

backends/candle/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::compute_cap::{
1313
use crate::models::{
1414
BertConfig, BertModel, DistilBertConfig, DistilBertModel, GTEConfig, GTEModel, JinaBertModel,
1515
JinaCodeBertModel, MPNetConfig, MPNetModel, MistralConfig, Model, ModernBertConfig,
16-
ModernBertModel, NomicBertModel, NomicConfig, Qwen2Config, Qwen3Config,
16+
ModernBertModel, NomicBertModel, NomicConfig, Qwen2Config, Qwen3Config, Qwen3Model,
1717
};
1818
#[cfg(feature = "cuda")]
1919
use crate::models::{
@@ -275,10 +275,10 @@ impl CandleBackend {
275275
"Qwen2 is only supported on Cuda devices in fp16 with flash attention enabled"
276276
.to_string(),
277277
)),
278-
(Config::Qwen3(_), Device::Cpu | Device::Metal(_)) => Err(BackendError::Start(
279-
"Qwen3 is only supported on Cuda devices in fp16 with flash attention enabled"
280-
.to_string(),
281-
)),
278+
(Config::Qwen3(config), Device::Cpu | Device::Metal(_)) => {
279+
tracing::info!("Starting Qwen3 model on {:?}", device);
280+
Ok(Box::new(Qwen3Model::load(vb, &config, model_type).s()?))
281+
},
282282
(Config::MPNet(config), _) => {
283283
tracing::info!("Starting MPNet model on {:?}", device);
284284
Ok(Box::new(MPNetModel::load(vb, &config, model_type).s()?))

backends/candle/src/models/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub use modernbert::{ModernBertConfig, ModernBertModel};
5959
pub use mpnet::{MPNetConfig, MPNetModel};
6060
pub use nomic::{NomicBertModel, NomicConfig};
6161
pub use qwen2::Qwen2Config;
62-
pub use qwen3::Qwen3Config;
62+
pub use qwen3::{Qwen3Config, Qwen3Model};
6363
use text_embeddings_backend_core::Batch;
6464

6565
#[cfg(feature = "cuda")]

0 commit comments

Comments
 (0)