Ship one binary with NPU + ROCm + CUDA support, fix CLI flag precedence
Adds breadmill's `full` feature (npu + rocm + cuda together) and switches the release workflow to build with it. All three backends are ort's load-dynamic (dlopen) mode, so combining them doesn't require the NPU/ROCm/ CUDA toolkits on the build host -- which backend is actually available is resolved at runtime via ORT_DYLIB_PATH / the dynamic linker, per whichever backend is selected for that run. Also fixes a real bug this surfaced: backend selection checked `config.model.backend == "rocm"` unconditionally in an if/else-if chain, so an explicit --cuda (or --npu) flag silently lost to an unrelated `backend` value already sitting in config.toml. CLI flags now always take priority over config. Version bump: breadmill 0.2.0 -> 0.2.1.
This commit is contained in:
parent
2618a33fd5
commit
fdf596e58a
5 changed files with 56 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "breadmill"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
|
||||
|
|
@ -14,6 +14,13 @@ npu = ["ort/vitis", "ort/load-dynamic"]
|
|||
# libonnxruntime_providers_rocm.so, which most distros don't package.
|
||||
rocm = ["ort/migraphx", "ort/load-dynamic"]
|
||||
cuda = ["ort/cuda", "ort/load-dynamic"]
|
||||
# All backends in one binary. Safe to combine: every backend here uses
|
||||
# ort's load-dynamic (dlopen) mode, so none of this links against an actual
|
||||
# NPU/ROCm/CUDA toolkit at build time — which ONNX Runtime actually gets
|
||||
# loaded (and thus which EPs are really available) is decided at runtime by
|
||||
# ORT_DYLIB_PATH / the dynamic linker, per the --npu/--rocm/--cuda flag or
|
||||
# `backend` config value in use for that run.
|
||||
full = ["npu", "rocm", "cuda"]
|
||||
|
||||
[[bin]]
|
||||
name = "breadmill"
|
||||
|
|
|
|||
|
|
@ -105,17 +105,34 @@ fn run_daemon(force_reindex: bool, use_npu: bool, use_rocm: bool, use_cuda: bool
|
|||
std::fs::create_dir_all(&state_dir).map_err(|e| e.to_string())?;
|
||||
std::fs::create_dir_all(&cache_dir).map_err(|e| e.to_string())?;
|
||||
|
||||
let backend = if use_npu || config.model.backend == "npu" {
|
||||
eprintln!("breadmill: NPU backend selected");
|
||||
Backend::Npu { cache_dir: cache_dir.clone() }
|
||||
} else if use_rocm || config.model.backend == "rocm" {
|
||||
eprintln!("breadmill: ROCm backend selected");
|
||||
Backend::Rocm
|
||||
} else if use_cuda || config.model.backend == "cuda" {
|
||||
eprintln!("breadmill: CUDA backend selected");
|
||||
Backend::Cuda
|
||||
// CLI flags always override config — otherwise an explicit --cuda/--npu on
|
||||
// the command line would silently lose to an unrelated `backend = "..."`
|
||||
// already sitting in config.toml, since that's whatever earlier branch a
|
||||
// fixed if/else-if priority order happened to check first.
|
||||
let backend_name = if use_npu {
|
||||
"npu"
|
||||
} else if use_rocm {
|
||||
"rocm"
|
||||
} else if use_cuda {
|
||||
"cuda"
|
||||
} else {
|
||||
Backend::Cpu
|
||||
config.model.backend.as_str()
|
||||
};
|
||||
|
||||
let backend = match backend_name {
|
||||
"npu" => {
|
||||
eprintln!("breadmill: NPU backend selected");
|
||||
Backend::Npu { cache_dir: cache_dir.clone() }
|
||||
}
|
||||
"rocm" => {
|
||||
eprintln!("breadmill: ROCm backend selected");
|
||||
Backend::Rocm
|
||||
}
|
||||
"cuda" => {
|
||||
eprintln!("breadmill: CUDA backend selected");
|
||||
Backend::Cuda
|
||||
}
|
||||
_ => Backend::Cpu,
|
||||
};
|
||||
|
||||
let store = Store::open(&state_dir, dim)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue