Skip to content

fix(classifiers): use Metal/CUDA device when available in candle classifiers#2399

Merged
bug-ops merged 1 commit intomainfrom
2396-candle-classifier-gpu
Mar 29, 2026
Merged

fix(classifiers): use Metal/CUDA device when available in candle classifiers#2399
bug-ops merged 1 commit intomainfrom
2396-candle-classifier-gpu

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 29, 2026

Summary

  • Extract detect_device() from candle_whisper.rs into a new crate-level crates/zeph-llm/src/device.rs module (gated under #[cfg(feature = "candle")])
  • Replace hardcoded Device::Cpu in all four candle classifiers (candle.rs, candle_pii.rs, three_class.rs, ner.rs) with crate::device::detect_device()
  • detect_device() tries Device::new_metal(0) under metal feature, Device::new_cuda(0) under cuda feature, falls back to Device::Cpu on any failure

Test plan

  • cargo +nightly fmt --check — PASS
  • cargo clippy --profile ci --workspace --features full -- -D warnings — PASS
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 7233/7233 PASS
  • cargo check --features candle -p zeph-llm — PASS (candle_whisper test module compiles correctly)

Closes #2396

@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 29, 2026
…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
@bug-ops bug-ops force-pushed the 2396-candle-classifier-gpu branch from 788fecd to bd0448b Compare March 29, 2026 23:24
@bug-ops bug-ops enabled auto-merge (squash) March 29, 2026 23:24
@bug-ops bug-ops merged commit 45694ec into main Mar 29, 2026
27 checks passed
@bug-ops bug-ops deleted the 2396-candle-classifier-gpu branch March 29, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(classifiers): candle classifier hardcoded to CPU — Metal/CUDA not used, model load takes >15s

1 participant