Skip to content

Commit

Permalink
Disable Resnext101_ATSS model on XPU (#3514)
Browse files Browse the repository at this point in the history
* diable resnext101_atss on XPU

* give detailed xpu device info to perf tag

* revert debug code

---------

Co-authored-by: kirill prokofiev <kirill.prokofiev@intel.com>
  • Loading branch information
eunwoosh and kprokofi authored May 17, 2024
1 parent e9c3c9b commit 7d89f03
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ max-returns = 10
convention = "google"

[tool.pytest.ini_options]
# TODO: Add cpu when OTX can run integration test parallelly for each task.
markers = [
"gpu: mark tests which require NVIDIA GPU device",
# "cpu: mark tests which require CPU device",
"gpu", # mark tests which require NVIDIA GPU
"cpu",
"xpu", # mark tests which require Intel dGPU
]
python_files = "tests/**/*.py"
9 changes: 9 additions & 0 deletions src/otx/algo/detection/atss.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
if TYPE_CHECKING:
from lightning.pytorch.cli import LRSchedulerCallable, OptimizerCallable
from torch import Tensor, nn
from typing_extensions import Self

from otx.core.metrics import MetricCallable

Expand Down Expand Up @@ -362,3 +363,11 @@ def _build_model(self, num_classes: int) -> SingleStageDetector:
test_cfg=test_cfg,
)
return SingleStageDetector(backbone, bbox_head, neck=neck, train_cfg=train_cfg, test_cfg=test_cfg)

def to(self, *args, **kwargs) -> Self:
"""Return a model with specified device."""
ret = super().to(*args, **kwargs)
if self.device.type == "xpu":
msg = f"{type(self).__name__} doesn't support XPU."
raise RuntimeError(msg)
return ret
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ def pytest_addoption(parser: pytest.Parser):
type=str,
help="Task type of OTX to use test.",
)
parser.addoption(
"--device",
action="store",
default="gpu",
type=str,
help="Which device to use.",
)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -344,10 +351,9 @@ def fxt_clean_up_mem_cache():
MemCacheHandlerSingleton.delete()


# TODO(Jaeguk): Add cpu param when OTX can run integration test parallelly for each task.
@pytest.fixture(scope="module", params=[pytest.param("gpu", marks=pytest.mark.gpu)])
@pytest.fixture(scope="session")
def fxt_accelerator(request: pytest.FixtureRequest) -> str:
return request.param
return request.config.getoption("--device", "gpu")


@pytest.fixture(params=set(OTXTaskType) - {OTXTaskType.DETECTION_SEMI_SL})
Expand Down
12 changes: 6 additions & 6 deletions tests/perf/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ def fxt_dataset(request: pytest.FixtureRequest, fxt_data_group) -> Benchmark.Dat


@pytest.fixture(scope="session")
def fxt_tags(fxt_user_name: str, fxt_version_tags: dict[str, str]) -> dict[str, str]:
def fxt_tags(fxt_user_name: str, fxt_version_tags: dict[str, str], fxt_accelerator: str) -> dict[str, str]:
"""Tag fields to record the machine and user executing this perf test."""
tags = {
**fxt_version_tags,
"user_name": fxt_user_name,
"machine_name": platform.node(),
"cpu_info": get_cpu_info()["brand_raw"],
"accelerator_info": subprocess.check_output(
["nvidia-smi", "-L"], # noqa: S603, S607
)
.decode()
.strip(),
}
if fxt_accelerator == "gpu":
tags["accelerator_info"] = subprocess.check_output(["nvidia-smi", "-L"]).decode().strip() # noqa: S603, S607
elif fxt_accelerator == "xpu":
raw = subprocess.check_output(args=["xpu-smi", "discovery", "--dump", "1,2"]).decode().strip()
tags["accelerator_info"] = "\n".join([ret.replace('"', "").replace(",", " : ") for ret in raw.split("\n")[1:]])
msg = f"{tags = }"
log.info(msg)
return tags
Expand Down
12 changes: 12 additions & 0 deletions tests/perf/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "dino_v2" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down Expand Up @@ -155,7 +159,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "dino_v2" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down Expand Up @@ -224,7 +232,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "dino_v2" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down
4 changes: 4 additions & 0 deletions tests/perf/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "atss_resnext101" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down
8 changes: 8 additions & 0 deletions tests/perf/test_instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "maskrcnn_r50" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down Expand Up @@ -196,7 +200,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "maskrcnn_r50" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down
4 changes: 4 additions & 0 deletions tests/perf/test_semantic_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ def test_perf(
fxt_model: Benchmark.Model,
fxt_dataset: Benchmark.Dataset,
fxt_benchmark: Benchmark,
fxt_accelerator: str,
):
if fxt_model.name == "dino_v2" and fxt_accelerator == "xpu":
pytest.skip(f"{fxt_model.name} doesn't support {fxt_accelerator}.")

self._test_perf(
model=fxt_model,
dataset=fxt_dataset,
Expand Down

0 comments on commit 7d89f03

Please sign in to comment.