Skip to content
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

[TKW] Distribute gpu tests #353

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/ci-tk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ jobs:
run: |
pip install --no-compile -r pytorch-rocm-requirements.txt
export WAVE_RUN_E2E_TESTS=1
WAVE_CACHE_ON=0 pytest -n 4 --capture=tee-sys -vv ./tests/kernel/wave/
export WAVE_DISTRIBUTE_GPU_TESTS=8
WAVE_CACHE_ON=0 pytest -n 8 --capture=tee-sys -vv ./tests/kernel/wave/

- name: Run e2e tests on AMD GPU MI250
if: "contains(matrix.os, 'mi250') && !cancelled()"
Expand Down
12 changes: 11 additions & 1 deletion iree/turbine/kernel/wave/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,18 @@ def all_equal(input_list: list[Any]) -> bool:
return all(elem == input_list[0] for elem in input_list)


DEFAULT_GPU_DEVICE = None


def get_default_gpu_device_name() -> str:
if DEFAULT_GPU_DEVICE is None:
return "cuda"

return f"cuda:{DEFAULT_GPU_DEVICE}"


def get_default_device() -> str:
return "cuda" if torch.cuda.is_available() else "cpu"
return get_default_gpu_device_name() if torch.cuda.is_available() else "cpu"


def to_default_device(tensor: torch.Tensor) -> torch.Tensor:
Expand Down
23 changes: 23 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import pytest
import os


def pytest_addoption(parser):
Expand All @@ -28,11 +29,33 @@ def pytest_configure(config):
)


DISTRIBUTE_GPU_TESTS = os.environ.get("WAVE_DISTRIBUTE_GPU_TESTS", None)


def _set_default_device(config):
if DISTRIBUTE_GPU_TESTS is None:
return

if not hasattr(config, "workerinput"):
return

worker_id = config.workerinput["workerid"]
if not worker_id.startswith("gw"):
return

device_id = int(worker_id[2:]) % int(DISTRIBUTE_GPU_TESTS)

import iree.turbine.kernel.wave.utils as utils

utils.DEFAULT_GPU_DEVICE = device_id


def _has_marker(item, marker):
return next(item.iter_markers(marker), None) is not None


def pytest_collection_modifyitems(config, items):
_set_default_device(config)
run_perf = config.getoption("--runperf")
for item in items:
is_validate_only = _has_marker(item, "validate_only")
Expand Down
Loading