Skip to content

Improvement: Simplifying GPU Test Strategy — Replace skipif with @pytest.mark.gpu Only #119

@jieyao-MilestoneHub

Description

@jieyao-MilestoneHub

Task Description

Our test suite currently applies both:

  • @pytest.mark.gpu
  • @pytest.mark.skipif(not torch.cuda.is_available(), ...)

on GPU-related tests.

However, based on our existing project workflow and pyproject.toml configuration:

  • GPU tests are already excluded by default via:

    addopts = ["-m", "not gpu and not slow"]
  • GPU tests are triggered only manually, e.g., pytest -m gpu

  • CUDA-dependent imports are already guarded using:

    pytest.importorskip("torch")
    pytest.importorskip("transformers")

Given these behaviors, the skipif decorator may be redundant and could unintentionally hide misconfigured environments, especially when someone intentionally runs pytest -m gpu but lacks a valid CUDA setup.

This issue proposes to evaluate whether GPU tests should use only @pytest.mark.gpu, removing the extra skipif layer to simplify the logic and make failures more explicit when GPU tests are intentionally invoked.

The goal is to align our testing strategy with how we already structure markers and CI execution.


Additional Context

  • GPU tests are currently excluded by default in pyproject.toml
  • GPU dependencies are guarded using pytest.importorskip
  • Running pytest -m gpu explicitly expresses intent to use a CUDA-enabled environment
  • Removing skipif may help surface configuration issues rather than silently skipping tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions