Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ The `--no-interactive` flag allows the CLI to accept commands via stdin and exit

- `CUDA`: Only supports >= CUDAv12 and might need to `sudo apt install libcudnn9-dev-cuda-12`
- `CoreML (Apple)`: Not advised for NLP models due to often large dimensionality.
- `ROCm` (AMD GPUs, Linux): Requires a ROCm runtime on the host (`rocm-hip-runtime`, `rocm-libs`) matching the ONNX Runtime build. Supported AMD Instinct accelerators are listed in the [ROCm compatibility matrix](https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html); select Radeon cards are also supported. When unsupported, ORT falls back to CPU. **Note:** upstream ONNX Runtime removed the ROCm execution provider in release 1.23. Newer ahnlich builds that bump the ORT pin should use `MIGraphX` instead.
- `MIGraphX` (AMD GPUs, Linux): AMD's recommended replacement for the ROCm provider in `onnxruntime >= 1.23`. Requires the `migraphx` runtime to be installed (ships in AMD's ROCm apt repository).

### Contributing

Expand Down
11 changes: 10 additions & 1 deletion ahnlich/ai/src/engine/ai/providers/ort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use executor::ExecutorWithSessionCache;
use hf_hub::{Cache, api::sync::ApiBuilder};
use ort::{
CUDAExecutionProvider, CoreMLExecutionProvider, DirectMLExecutionProvider, ExecutionProvider,
SessionBuilder, SessionOutputs, TensorRTExecutionProvider,
MIGraphXExecutionProvider, ROCmExecutionProvider, SessionBuilder, SessionOutputs,
TensorRTExecutionProvider,
};
use strum::EnumIter;

Expand Down Expand Up @@ -49,6 +50,8 @@ pub(crate) enum InnerAIExecutionProvider {
CUDA,
DirectML,
CoreML,
ROCm,
MIGraphX,
#[default]
CPU,
}
Expand All @@ -60,6 +63,8 @@ impl From<AIExecutionProvider> for InnerAIExecutionProvider {
AIExecutionProvider::Cuda => InnerAIExecutionProvider::CUDA,
AIExecutionProvider::DirectMl => InnerAIExecutionProvider::DirectML,
AIExecutionProvider::CoreMl => InnerAIExecutionProvider::CoreML,
AIExecutionProvider::Rocm => InnerAIExecutionProvider::ROCm,
AIExecutionProvider::Migraphx => InnerAIExecutionProvider::MIGraphX,
}
}
}
Expand All @@ -77,6 +82,10 @@ fn register_provider(
DirectMLExecutionProvider::default().register(builder)?
}
InnerAIExecutionProvider::CoreML => CoreMLExecutionProvider::default().register(builder)?,
InnerAIExecutionProvider::ROCm => ROCmExecutionProvider::default().register(builder)?,
InnerAIExecutionProvider::MIGraphX => {
MIGraphXExecutionProvider::default().register(builder)?
}
InnerAIExecutionProvider::CPU => (),
};
Ok(())
Expand Down
2 changes: 2 additions & 0 deletions ahnlich/dsl/src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ fn parse_to_execution_provider(input: &str) -> Result<ExecutionProvider, DslErro
"coreml" => Ok(ExecutionProvider::CoreMl),
"directml" => Ok(ExecutionProvider::DirectMl),
"tensorrt" => Ok(ExecutionProvider::TensorRt),
"rocm" => Ok(ExecutionProvider::Rocm),
"migraphx" => Ok(ExecutionProvider::Migraphx),
a => Err(DslError::UnsupportedPreprocessingMode(a.to_string())),
}
}
Expand Down
4 changes: 3 additions & 1 deletion ahnlich/dsl/src/syntax/syntax.pest
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ algorithm = {
^"cosinesimilarity" |
"dotproductsimilarity"
}
execution_provider = {
execution_provider = {
^"coreml" |
^"tensorrt" |
^"directml" |
^"migraphx" |
^"rocm" |
"cuda"
}
non_linear_algorithms = { non_linear_algorithm ~ (whitespace* ~ "," ~ whitespace* ~ non_linear_algorithm)* }
Expand Down
41 changes: 41 additions & 0 deletions ahnlich/dsl/src/tests/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,44 @@ fn test_set_in_store_parse() {
})]
);
}

#[test]
fn test_get_sim_n_parse_rocm_execution_provider() {
let input = r#"GETSIMN 3 with [find me] using cosinesimilarity executionprovider rocm in store1"#;
assert_eq!(
parse_ai_query(input).expect("Could not parse query input"),
vec![AiQuery::GetSimN(GetSimN {
store: "store1".to_string(),
search_input: Some(StoreInput {
value: Some(StoreValue::RawString("find me".to_string()))
}),
closest_n: 3,
algorithm: Algorithm::CosineSimilarity as i32,
condition: None,
preprocess_action: PreprocessAction::NoPreprocessing as i32,
execution_provider: Some(ExecutionProvider::Rocm as i32),
model_params: HashMap::new(),
})]
);
}

#[test]
fn test_get_sim_n_parse_migraphx_execution_provider() {
let input =
r#"GETSIMN 3 with [find me] using cosinesimilarity executionprovider migraphx in store1"#;
assert_eq!(
parse_ai_query(input).expect("Could not parse query input"),
vec![AiQuery::GetSimN(GetSimN {
store: "store1".to_string(),
search_input: Some(StoreInput {
value: Some(StoreValue::RawString("find me".to_string()))
}),
closest_n: 3,
algorithm: Algorithm::CosineSimilarity as i32,
condition: None,
preprocess_action: PreprocessAction::NoPreprocessing as i32,
execution_provider: Some(ExecutionProvider::Migraphx as i32),
model_params: HashMap::new(),
})]
);
}
15 changes: 15 additions & 0 deletions ahnlich/types/src/ai/execution_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ pub enum ExecutionProvider {
Cuda = 1,
DirectMl = 2,
CoreMl = 3,
/// ROCm execution provider for AMD GPUs (Linux + supported AMD Instinct /
/// Radeon hardware). Requires the host to have a matching ROCm runtime
/// installed and the ort/onnxruntime build configured with ROCm support.
/// Note: upstream onnxruntime removed the ROCm provider in 1.23; for newer
/// ORT builds prefer MIGRAPHX.
Rocm = 4,
/// MIGraphX execution provider for AMD GPUs (Linux + supported AMD Instinct
/// hardware). AMD's recommended replacement for the ROCm provider in
/// onnxruntime >= 1.23. Requires the host to have the MIGraphX runtime
/// installed (ships in AMD's ROCm apt repository).
Migraphx = 5,
}
impl ExecutionProvider {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -19,6 +30,8 @@ impl ExecutionProvider {
Self::Cuda => "CUDA",
Self::DirectMl => "DIRECT_ML",
Self::CoreMl => "CORE_ML",
Self::Rocm => "ROCM",
Self::Migraphx => "MIGRAPHX",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand All @@ -28,6 +41,8 @@ impl ExecutionProvider {
"CUDA" => Some(Self::Cuda),
"DIRECT_ML" => Some(Self::DirectMl),
"CORE_ML" => Some(Self::CoreMl),
"ROCM" => Some(Self::Rocm),
"MIGRAPHX" => Some(Self::Migraphx),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion protos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Defines server types and client connections.
### **AI & Algorithm Definitions**
- `algorithm.proto`: Defines similarity algorithms (e.g., `CosineSimilarity`).
- `ai/models.proto`: Defines AI models available for use.
- `ai/execution_provider.proto`: Specifies execution providers (e.g., `CUDA`, `TENSOR_RT`).
- `ai/execution_provider.proto`: Specifies execution providers (e.g., `CUDA`, `TENSOR_RT`, `ROCM`, `MIGRAPHX`).

## **Usage**
To use these protofiles, generate language-specific gRPC stubs:
Expand Down
11 changes: 11 additions & 0 deletions protos/ai/execution_provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ enum ExecutionProvider {
CUDA = 1;
DIRECT_ML = 2;
CORE_ML = 3;
// ROCm execution provider for AMD GPUs (Linux + supported AMD Instinct /
// Radeon hardware). Requires the host to have a matching ROCm runtime
// installed and the ort/onnxruntime build configured with ROCm support.
// Note: upstream onnxruntime removed the ROCm provider in 1.23; for newer
// ORT builds prefer MIGRAPHX.
ROCM = 4;
// MIGraphX execution provider for AMD GPUs (Linux + supported AMD Instinct
// hardware). AMD's recommended replacement for the ROCm provider in
// onnxruntime >= 1.23. Requires the host to have the MIGraphX runtime
// installed (ships in AMD's ROCm apt repository).
MIGRAPHX = 5;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions sdk/ahnlich-client-node/grpc/ai/execution_provider_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,35 @@ export enum ExecutionProvider {
* @generated from enum value: CORE_ML = 3;
*/
CORE_ML = 3,

/**
* ROCm execution provider for AMD GPUs (Linux + supported AMD Instinct /
* Radeon hardware). Requires the host to have a matching ROCm runtime
* installed and the ort/onnxruntime build configured with ROCm support.
* Note: upstream onnxruntime removed the ROCm provider in 1.23; for newer
* ORT builds prefer MIGRAPHX.
*
* @generated from enum value: ROCM = 4;
*/
ROCM = 4,

/**
* MIGraphX execution provider for AMD GPUs (Linux + supported AMD Instinct
* hardware). AMD's recommended replacement for the ROCm provider in
* onnxruntime >= 1.23. Requires the host to have the MIGraphX runtime
* installed (ships in AMD's ROCm apt repository).
*
* @generated from enum value: MIGRAPHX = 5;
*/
MIGRAPHX = 5,
}
// Retrieve enum metadata with: proto3.getEnumType(ExecutionProvider)
proto3.util.setEnumType(ExecutionProvider, "ai.execution_provider.ExecutionProvider", [
{ no: 0, name: "TENSOR_RT" },
{ no: 1, name: "CUDA" },
{ no: 2, name: "DIRECT_ML" },
{ no: 3, name: "CORE_ML" },
{ no: 4, name: "ROCM" },
{ no: 5, name: "MIGRAPHX" },
]);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.