Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest filtering markers for GPU to improve workflows #72

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

liweintu
Copy link
Contributor

@liweintu liweintu commented Sep 9, 2024

To address issue #28 , we add pytest filtering markers for GPU based on its availability.

@liweintu liweintu linked an issue Sep 9, 2024 that may be closed by this pull request
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 95a57e7 to 597ae84 Compare September 13, 2024 06:10
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 39dc209 to cf8f1e9 Compare September 13, 2024 06:15
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from a43d54f to 0bbb7c3 Compare September 13, 2024 06:28
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from efe21eb to e1e9b91 Compare September 13, 2024 06:37
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 45b0e34 to e8dee44 Compare September 13, 2024 06:43
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 27b70bc to 490f0ec Compare September 13, 2024 07:41
Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.92%. Comparing base (53382b8) to head (434932a).
Report is 442 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #72       +/-   ##
==========================================
- Coverage   33.13%   9.92%   -23.22%     
==========================================
  Files           3      10        +7     
  Lines         172     393      +221     
==========================================
- Hits           57      39       -18     
- Misses        115     354      +239     
Flag Coverage Δ
unittests 9.92% <ø> (-23.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 9cb70fc to 3a6d6e0 Compare September 17, 2024 06:38
@Vinitha-balachandran Vinitha-balachandran force-pushed the pytest-mark-for-cuda-availability branch from 207ce6a to 2694731 Compare September 17, 2024 06:43
@liweintu
Copy link
Contributor Author

The pytest mark filtering can work and pass now. But the CI encountered a permission issue when running the following codecov create-commit command. @alecandido Do we need to adjust some settings to grant the permission? Thanks.

==> Running command '/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov create-commit'
/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov create-commit --git-service github -Z
info - 2024-09-18 09:28:14,787 -- ci service found: github-actions
info - 2024-09-18 09:28:14,959 -- Process Commit creating complete
error - 2024-09-18 09:28:14,959 -- Commit creating failed: {"detail":"You do not have permission to perform this action."}
Error: Codecov: Failed to properly create commit: The process '/home/runner/work/_actions/codecov/codecov-action/v4/dist/codecov' failed with exit code 1

@scarrazza
Copy link
Member

@liweintu I have reset the codecov token and now tests are working.

@liweintu
Copy link
Contributor Author

Thanks @scarrazza! Now all checks can pass, we'll proceed to review and merge this PR.

pyproject.toml Outdated
@@ -26,6 +26,7 @@ quimb = { version = "^1.6.0", extras = ["tensor"] }
cupy-cuda11x = { version = "^11.6.0", optional = true }
cuquantum-python-cu11 = { version = "^23.3.0", optional = true }
mpi4py = { version = "^3.1.5", optional = true }
qibojit = { git = "https://github.com/qiboteam/qibojit.git" }
Copy link
Member

Choose a reason for hiding this comment

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

Why is Qibotn now depending on Qibojit?

Copy link
Contributor

Choose a reason for hiding this comment

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

Qibotn had qibojit dependency earlier in the tests. So far we were installing qibojit seperately. Since, the previous version of workflow was skipping tests it was not an issue in github actions. But, now in the absence of qibojit tests will fail.

Copy link
Member

Choose a reason for hiding this comment

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

But you should not run tests on Qibojit, since you're explicitly testing another backend (i.e. Qibotn).

Could you point me to the logs where tests are failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the question here is "Does Qibotn need to depend on Qibojit?". My quick answer is "No, it doesn't."

So I removed qibojit package, ran pytest, and encountered an error below.

        # Test qibo
>       qibo.set_backend(backend=config.qibo.backend, platform=config.qibo.platform)

tests/test_quimb_backend.py:45:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../miniforge3/envs/py311/lib/python3.11/site-packages/qibo/backends/__init__.py:150: in set_backend
    GlobalBackend.set_backend(backend, **kwargs)
../../miniforge3/envs/py311/lib/python3.11/site-packages/qibo/backends/__init__.py:108: in set_backend
    cls._instance = construct_backend(backend, **kwargs)
../../miniforge3/envs/py311/lib/python3.11/site-packages/qibo/backends/__init__.py:230: in construct_backend
    raise_error(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

exception = <class 'ValueError'>
message = "The 'qibojit' backends' provider is not available. Check that a Python package named 'qibojit' is installed, and it is exposing valid Qibo backends."

I guess it's due to qibojit being the first and default choice during backend construction. If my guess is correct, maybe we specify the backend to be numpy for test cases of quimb instead of using the default backend?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's due to qibojit being the first and default choice during backend construction. If my guess is correct, maybe we specify the backend to be numpy for test cases of quimb instead of using the default backend?

This is a known problem, already solved recently qiboteam/qibo#1430

The point is that you should not encounter that problem, since you should set Qibotn as the backend, and not relying on the default one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, will modify the tests to remove the dependency

@@ -42,7 +42,7 @@ def test_eval(nqubits: int, tolerance: float, is_mps: bool):
init_state_tn = copy.deepcopy(init_state)

# Test qibo
qibo.set_backend(backend=config.qibo.backend, platform=config.qibo.platform)
qibo.set_backend("numpy")
Copy link
Member

Choose a reason for hiding this comment

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

Ok, that's even fine by me, but maybe you wanted to change

qibo = Executor(backend="qibojit", platform="numpy")

Otherwise, you can decide to drop that file, and inline the values in the tests (that is a pretty good option).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can drop that file as it is doing nothing. Need to modify cuquantum side also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I like the latter option because it explicitly avoids the dependency on qibojit.

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.

Improve workflows for CUDA availability
4 participants