-
Notifications
You must be signed in to change notification settings - Fork 846
feat(inspect): add training device selection #3056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maxxgx
merged 5 commits into
open-edge-platform:feature/geti-inspect
from
maxxgx:max/select-training-devices
Oct 27, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
application/backend/src/api/endpoints/devices_endpoints.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright (C) 2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from fastapi import APIRouter | ||
|
|
||
| from api.endpoints import API_PREFIX | ||
| from pydantic_models.devices import DeviceList | ||
| from utils.devices import Devices | ||
|
|
||
| device_router = APIRouter( | ||
| prefix=API_PREFIX, | ||
| tags=["Job"], | ||
| ) | ||
|
|
||
|
|
||
| @device_router.get("/inference-devices") | ||
| async def get_inference_devices() -> DeviceList: | ||
| """Endpoint to get list of supported devices for inference""" | ||
| return DeviceList(devices=Devices.inference_devices()) | ||
|
|
||
|
|
||
| @device_router.get("/training-devices") | ||
| async def get_training_devices() -> DeviceList: | ||
| """Endpoint to get list of supported devices for training""" | ||
| return DeviceList(devices=Devices.training_devices()) |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Copyright (C) 2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from pydantic import BaseModel | ||
|
|
||
|
|
||
| class DeviceList(BaseModel): | ||
| devices: list[str] | ||
|
|
||
| model_config = { | ||
| "json_schema_extra": { | ||
| "example": { | ||
| "devices": ["CPU", "XPU", "NPU"], | ||
| } | ||
| } | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # Copyright (C) 2025 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from functools import lru_cache | ||
|
|
||
| import openvino as ov | ||
| from lightning.pytorch.accelerators import AcceleratorRegistry | ||
|
|
||
|
|
||
| class Devices: | ||
| """Utility class for device-related operations.""" | ||
| @staticmethod | ||
| @lru_cache | ||
| def training_devices() -> list[str]: | ||
| """Get list of supported devices for training.""" | ||
| devices = [] | ||
| for device_name, device_info in AcceleratorRegistry.items(): | ||
| accelerator = device_info["accelerator"] | ||
| if accelerator.is_available(): | ||
| devices.append(device_name.casefold()) | ||
| return devices | ||
|
|
||
| @staticmethod | ||
| @lru_cache | ||
| def inference_devices() -> list[str]: | ||
maxxgx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """Get list of supported devices for inference.""" | ||
| ov_core = ov.Core() | ||
| return [device.casefold() for device in ov_core.available_devices] | ||
|
|
||
| @classmethod | ||
| @lru_cache | ||
| def _is_device_supported(cls, device_name: str, for_training: bool = False) -> bool: | ||
| """Check if a device is supported for inference or training. | ||
|
|
||
| Args: | ||
| device_name (str): Name of the device to check. | ||
| for_training (bool): If True, check for training devices; otherwise, check for inference devices. | ||
|
|
||
| Returns: | ||
| bool: True if the device is supported, False otherwise. | ||
| """ | ||
| device_name = device_name.casefold() | ||
| if for_training: | ||
| return device_name in cls.training_devices() | ||
| return device_name in cls.inference_devices() | ||
|
|
||
| @classmethod | ||
| def is_device_supported_for_inference(cls, device_name: str) -> bool: | ||
| """Check if a device is supported for inference. | ||
|
|
||
| Args: | ||
| device_name (str): Name of the device to check. | ||
|
|
||
| Returns: | ||
| bool: True if the device is supported for inference, False otherwise. | ||
| """ | ||
| return cls._is_device_supported(device_name, for_training=False) | ||
|
|
||
| @classmethod | ||
| def is_device_supported_for_training(cls, device_name: str) -> bool: | ||
| """Check if a device is supported for training. | ||
|
|
||
| Args: | ||
| device_name (str): Name of the device to check. | ||
|
|
||
| Returns: | ||
| bool: True if the device is supported for training, False otherwise. | ||
| """ | ||
| return cls._is_device_supported(device_name, for_training=True) | ||
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.