fix(classifiers): use Metal/CUDA device when available in candle classifiers#2399
Merged
fix(classifiers): use Metal/CUDA device when available in candle classifiers#2399
Conversation
…sifiers Hardcoded Device::Cpu in all four candle classifiers (candle.rs, candle_pii.rs, three_class.rs, ner.rs) prevented Metal/CUDA from being used on Apple Silicon and CUDA hardware, causing model load times exceeding 15s for piiranha (1.1 GB) and DeBERTa. Extract detect_device() from candle_whisper.rs into a new crate-level crates/zeph-llm/src/device.rs module (gated under #[cfg(feature = "candle")]) and call it from all five sites. Function tries Device::new_metal(0) under metal feature, Device::new_cuda(0) under cuda feature, falls back to Device::Cpu on any failure. Closes #2396
788fecd to
bd0448b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
detect_device()fromcandle_whisper.rsinto a new crate-levelcrates/zeph-llm/src/device.rsmodule (gated under#[cfg(feature = "candle")])Device::Cpuin all four candle classifiers (candle.rs,candle_pii.rs,three_class.rs,ner.rs) withcrate::device::detect_device()detect_device()triesDevice::new_metal(0)undermetalfeature,Device::new_cuda(0)undercudafeature, falls back toDevice::Cpuon any failureTest plan
cargo +nightly fmt --check— PASScargo clippy --profile ci --workspace --features full -- -D warnings— PASScargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 7233/7233 PASScargo check --features candle -p zeph-llm— PASS (candle_whisper test module compiles correctly)Closes #2396