Skip to content

Move CUDA device probe in test_symbol_exposure.py from import time to test execution #361

Description

@coderabbitai

Summary

Module-level Device(0) initialization in numbast/src/numbast/experimental/mlir/tools/tests/test_symbol_exposure.py (lines 8–12) runs at pytest collection time, which blocks collection on machines without a CUDA runtime and prevents graceful skip behavior.

Details

# Current problematic code (lines 8-12)
from cuda.core.experimental import Device

dev = Device(0)
cc = dev.compute_capability

The codebase already uses fixture-based device queries elsewhere (e.g., conftest.py:arch_str() and test_shim_writer.py:cc()). The probe should be moved inside the test function (or a fixture), with a pytest.skip fallback if CUDA is unavailable.

Suggested fix

Move Device(0) into the test body and wrap with try/except:

def test_symbol_exposure(run_in_isolated_folder, arch_str):
    try:
        cc = Device(0).compute_capability
    except Exception as e:
        pytest.skip(f"CUDA device unavailable for symbol-exposure test: {e}")
    ...

Or alternatively, reuse the existing arch_str fixture (defined in conftest.py) which already derives the compute capability at test execution time.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions