You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ProviderOptions level device filtering and APIs to configure model level device filtering (microsoft#1744)
# Goal
This PR replaces the existing device filtering at the model
configuration level by adding device filtering parameters to
ProviderOptions level, as a first step to support running different
parts of a GenAI model (e.g. one configured by decoder pipeline) on
different CPU/GPU/NPU devices in the future.
In addition, this PR adds the following APIs to allow setting/clearing
device filtering options at the model level, which effectively updates
`config.model.decoder.session_options.provider_options.device_filtering_options`,
based on previous work of @jiaxuwu2021 . This capability is crucial for
running the same GenAI model in different hardware environments by
selecting the inference device programmatically, as well as automated
testing of EPs.
- `SetDecoderProviderOptionsHardwareDeviceType` (native and C#)
`set_decoder_provider_options_hardware_device_type` (Python)
- `SetDecoderProviderOptionsHardwareDeviceId` (native and C#)
`set_decoder_provider_options_hardware_device_id` (Python)
- `SetDecoderProviderOptionsHardwareVendorId` (native and C#)
`set_decoder_provider_options_hardware_vendor_id` (Python)
- `ClearDecoderProviderOptionsHardwareDeviceType` (native and C#)
`clear_decoder_provider_options_hardware_device_type` (Python)
- `ClearDecoderProviderOptionsHardwareDeviceId` (native and C#)
`clear_decoder_provider_options_hardware_device_id` (Python)
- `ClearDecoderProviderOptionsHardwareVendorId` (native and C#)
`clear_decoder_provider_options_hardware_vendor_id` (Python)
# Usage
Old `genai_config.json` format (to be replaced by this PR)
```json
{
"model": {
...
"hardware_device_type": "CPU",
"hardware_device_id": 7,
"hardware_vendor_id": 32902,
...
}
}
```
New `genai_config.json` format:
```json
{
"model": {
...
"decoder": {
"session_options": {
...
"provider_options": [
{
"OpenVINO": {
...
"device_filtering_options": {
"hardware_device_type": "CPU",
"hardware_device_id": 7,
"hardware_vendor_id": 32902
}
}
}
]
},
...
},
...
},
...
}
```
# Unit tests
The new APIs are tested in case `CAPITests` of `test/c_api_tests.cpp`
---------
Co-authored-by: Yi Ren <[email protected]>
Co-authored-by: jiaxuwu2021 <[email protected]>
0 commit comments