Skip to content

Pytest CUDA Marker#1220

Open
jeff-hykin wants to merge 5 commits intodevfrom
jeff/cuda_tests_marker
Open

Pytest CUDA Marker#1220
jeff-hykin wants to merge 5 commits intodevfrom
jeff/cuda_tests_marker

Conversation

@jeff-hykin
Copy link
Member

GPU tests are different than cuda tests (most GPU tests run on MacOS, its only the cuda ones that dont)

assert model.intrinsic == new_intrinsics


@pytest.mark.gpu
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: this one doesnt require cuda, even though its still metric3d (only some of the metric3d tests need cuda)

@greptile-apps
Copy link

greptile-apps bot commented Feb 8, 2026

Greptile Overview

Greptile Summary

This PR introduces a new @pytest.mark.cuda marker to distinguish between general GPU tests (which can run on macOS with Metal) and CUDA-specific tests (which require NVIDIA CUDA). The implementation adds a pytest hook in conftest.py that automatically skips CUDA tests when torch.cuda.is_available() returns False.

Key changes:

  • Added _has_cuda() helper and pytest_collection_modifyitems hook to auto-skip CUDA tests
  • Registered cuda marker in pyproject.toml pytest configuration
  • Applied @pytest.mark.cuda to 3 Metric3D tests and 1 ContactGraspNet test that require CUDA

Issues found:

  • Two Metric3D tests (test_metric3d_update_intrinsic and test_metric3d_update_intrinsic_invalid) are missing the @pytest.mark.cuda marker even though they instantiate Metric3D, which defaults to device="cuda". These tests will fail on non-CUDA systems.

Confidence Score: 3/5

  • This PR is mostly safe but has incomplete marker coverage that could cause test failures
  • The implementation is correct and the pytest hook works properly, but two tests in test_metric3d.py are missing the cuda marker despite requiring CUDA. This inconsistency means these tests will fail on non-CUDA systems instead of being properly skipped.
  • Pay close attention to dimos/models/depth/test_metric3d.py - ensure all tests that instantiate Metric3D have the cuda marker

Important Files Changed

Filename Overview
dimos/conftest.py Added pytest hook to automatically skip tests marked with @pytest.mark.cuda when CUDA is not available
pyproject.toml Registered new cuda pytest marker for tests requiring CUDA-specific GPU acceleration
dimos/models/depth/test_metric3d.py Added @pytest.mark.cuda to 3 tests that require CUDA, but 2 other GPU tests still lack the marker despite instantiating Metric3D
dimos/models/manipulation/contact_graspnet_pytorch/test_contact_graspnet.py Added @pytest.mark.cuda to integration test that requires CUDA for contact graspnet inference

Sequence Diagram

sequenceDiagram
    participant Pytest
    participant conftest
    participant torch
    participant Test

    Note over Pytest: Test Collection Phase
    Pytest->>conftest: pytest_collection_modifyitems(config, items)
    conftest->>conftest: _has_cuda()
    conftest->>torch: import torch
    conftest->>torch: torch.cuda.is_available()
    torch-->>conftest: True/False
    
    alt CUDA not available
        conftest->>conftest: Create skip marker
        loop For each test item
            conftest->>Test: item.get_closest_marker("cuda")
            alt Has cuda marker
                conftest->>Test: item.add_marker(skip_marker)
                Note over Test: Test will be skipped
            end
        end
    else CUDA available
        Note over conftest: No action, tests run normally
    end
    
    Note over Pytest: Test Execution Phase
    Pytest->>Test: Run test_metric3d_init()
    Note over Test: @pytest.mark.cuda<br/>@pytest.mark.gpu
    alt CUDA available
        Test->>Test: Execute test
    else CUDA not available
        Note over Test: Skipped: CUDA is not available
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

assert model.intrinsic == new_intrinsics


@pytest.mark.gpu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @pytest.mark.cuda - this test instantiates Metric3D which defaults to device="cuda" (metric3d.py:35), so it requires CUDA to run.

Suggested change
@pytest.mark.gpu
@pytest.mark.cuda
@pytest.mark.gpu

@greptile-apps
Copy link

greptile-apps bot commented Feb 8, 2026

Additional Comments (1)

dimos/models/depth/test_metric3d.py
Missing @pytest.mark.cuda - this test instantiates Metric3D which defaults to device="cuda" (metric3d.py:35), so it requires CUDA to run.

@pytest.mark.cuda
@pytest.mark.gpu

paul-nechifor
paul-nechifor previously approved these changes Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants