Compare commits

...

2 Commits

Author SHA1 Message Date
bo0tzz
54ada4db71 chore: move env var to runner env 2026-07-13 17:12:01 +02:00
bo0tzz
d90bb66daa feat: ML hardware acceleration testing on pokedex 2026-07-13 16:54:01 +02:00
4 changed files with 82 additions and 1 deletions

View File

@@ -636,6 +636,49 @@ jobs:
- name: Run ci-unit
run: mise run ci-unit
ml-hwaccel-tests:
name: HW Accel Test ML (${{ matrix.name }})
needs: pre-job
if: ${{ fromJSON(needs.pre-job.outputs.should_run).machine-learning == true }}
strategy:
fail-fast: false
matrix:
include:
- name: nvidia-ampere
runner: pokedex-dgpu-nvidia-ampere
device: cuda
expected-ep: CUDAExecutionProvider
runs-on: ${{ matrix.runner }}
permissions:
contents: read
defaults:
run:
working-directory: ./machine-learning
env:
IMMICH_HWACCEL_EXPECTED_EP: ${{ matrix.expected-ep }}
steps:
- id: token
uses: immich-app/devtools/actions/create-workflow-token@9db058b2e6eec20e07760b0e17a0505c78ec3191 # create-workflow-token-action-v2.0.1
with:
client-id: ${{ secrets.PUSH_O_MATIC_APP_CLIENT_ID }}
private-key: ${{ secrets.PUSH_O_MATIC_APP_KEY }}
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
token: ${{ steps.token.outputs.token }}
- name: Setup Mise
uses: immich-app/devtools/actions/use-mise@3bca63ca3c15020293b36b51737a3ee2c773340b # use-mise-action-v3.1.0
with:
github_token: ${{ steps.token.outputs.token }}
- name: Install
run: mise run install --extra ${{ matrix.device }}
- name: Run hardware tests
run: mise run test-hardware
github-files-formatting:
name: .github Files Formatting
needs: pre-job

View File

@@ -14,6 +14,9 @@ run = "uv run pytest --cov=immich_ml --cov-report term-missing"
[tasks.format]
run = "uv run ruff format immich_ml"
[tasks.test-hardware]
run = "uv run pytest -m gpu test_hardware.py"
[tasks.check]
run = "uv run mypy --strict immich_ml/"

View File

@@ -92,4 +92,4 @@ select = ["E", "F", "I"]
per-file-ignores = { "test_main.py" = ["F403"] }
[tool.pytest.ini_options]
markers = ["providers", "ov_device_ids"]
markers = ["providers", "ov_device_ids", "gpu"]

View File

@@ -0,0 +1,35 @@
import os
import pytest
from PIL import Image
from immich_ml.models import from_model_type
from immich_ml.schemas import ModelTask, ModelType
pytestmark = pytest.mark.gpu
EXPECTED_EP = os.environ.get("IMMICH_HWACCEL_EXPECTED_EP")
@pytest.fixture(autouse=True)
def require_hwaccel_run() -> None:
if not EXPECTED_EP:
pytest.skip("IMMICH_HWACCEL_EXPECTED_EP unset; not a hardware run")
MODELS = [
pytest.param("ViT-B-32__openai", ModelType.VISUAL, ModelTask.SEARCH, id="clip-visual"),
]
@pytest.mark.parametrize("model_name, model_type, model_task", MODELS)
def test_hwaccel_engaged(model_name: str, model_type: ModelType, model_task: ModelTask) -> None:
model = from_model_type(model_name, model_type, model_task)
model.load()
# a CPU fallback returns the same output, so the provider list is the only fallback signal
assert EXPECTED_EP in model.session.providers, (
f"expected {EXPECTED_EP}, session resolved to {model.session.providers}"
)
model.predict(Image.new("RGB", (224, 224)))