Skip to content

Commit 05f0e50

Browse files
author
Bhanu Teja Goshikonda
committed
test(pytorch): move test_import_gpu cases to single_gpu suite
test_import_gpu[transformer_engine] fails on the CPU-only default-runner that unit-test runs on because TE 2.17 dlopens libcuda.so.1 at import time; libcuda is only mounted into containers via nvidia-container-cli when a GPU is present. The test is correctly gated with @pytest.mark.skipif(not IS_CUDA) — that gate is about the IMAGE variant (CUDA vs CPU), not about the test runner's GPU availability. Moving both parametrized cases (flash_attn, transformer_engine) into single_gpu/ where the workflow runs on x86-g6xl-runner with --gpus all gives them a real driver mount at import time. flash_attn passed on the CPU fleet only because it defers libcuda dlopen until the first CUDA call — the import itself succeeded. Moving it too keeps GPU-only import checks in a single suite and avoids relying on that lazy-loading behavior. The IS_CUDA skip is preserved as a belt-and-suspenders guard for any future CPU-variant coverage that reuses the single_gpu suite. Unit suite retains COMMON_PACKAGES (torch, torchvision, torchaudio, deepspeed, boto3, requests, yaml, packaging) — none of which need a GPU driver at import.
1 parent af4e110 commit 05f0e50

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Verify GPU-only Python packages import successfully.
2+
3+
TE 2.17 dlopens libcuda.so.1 at import time; libcuda is only mounted into
4+
containers via nvidia-container-cli when a GPU is present. That means these
5+
imports must run on the single-GPU fleet (--gpus all), not on the CPU-only
6+
default-runner used for unit tests. The IS_CUDA skip is kept as a
7+
belt-and-suspenders guard for CPU-variant images.
8+
"""
9+
10+
import importlib
11+
import os
12+
13+
import pytest
14+
15+
IS_CUDA = os.path.isdir("/usr/local/cuda")
16+
17+
GPU_PACKAGES = [
18+
"flash_attn",
19+
"transformer_engine",
20+
]
21+
22+
23+
@pytest.mark.skipif(not IS_CUDA, reason="CUDA-only package")
24+
@pytest.mark.parametrize("package", GPU_PACKAGES)
25+
def test_import_gpu(package):
26+
importlib.import_module(package)

test/pytorch/unit/test_imports.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""Verify key Python packages import successfully."""
22

33
import importlib
4-
import os
54

65
import pytest
76

8-
IS_CUDA = os.path.isdir("/usr/local/cuda")
9-
107
COMMON_PACKAGES = [
118
"torch",
129
"torchvision",
@@ -18,18 +15,7 @@
1815
"packaging",
1916
]
2017

21-
GPU_PACKAGES = [
22-
"flash_attn",
23-
"transformer_engine",
24-
]
25-
2618

2719
@pytest.mark.parametrize("package", COMMON_PACKAGES)
2820
def test_import(package):
2921
importlib.import_module(package)
30-
31-
32-
@pytest.mark.skipif(not IS_CUDA, reason="CUDA-only package")
33-
@pytest.mark.parametrize("package", GPU_PACKAGES)
34-
def test_import_gpu(package):
35-
importlib.import_module(package)

0 commit comments

Comments
 (0)