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

fixing cupy tests failing #1147

Merged
merged 5 commits into from
Dec 26, 2023
Merged

fixing cupy tests failing #1147

merged 5 commits into from
Dec 26, 2023

Conversation

scarrazza
Copy link
Member

@scarrazza scarrazza commented Dec 21, 2023

Closes #1072 and fixes further cupy failures in the quantum_info module.

Checklist:

  • Reviewers confirm new code works as expected.
  • Tests are passing.
  • Coverage does not decrease.
  • Documentation is updated.

@scarrazza
Copy link
Member Author

@renatomello, I have applied some changes to the diamond_norm because when running all tests together the global backend is changed and does not match qibojit-cupy, therefore the call to to_numpy does not work as expected and we get this:

FAILED tests/test_quantum_info_metrics.py::test_diamond_norm[qibojit-cupy-1] - TypeError: Implicit conversion to a NumPy array is not allowed. Please use `.get()` to construct a NumPy array explicitly.
FAILED tests/test_quantum_info_metrics.py::test_diamond_norm[qibojit-cupy-2] - TypeError: Implicit conversion to a NumPy array is not allowed. Please use `.get()` to construct a NumPy array explicitly.

@scarrazza
Copy link
Member Author

@stavros11, I have fixed the issue reported in #1072 by reducing the memory required by the specific test. We had a similar problem back in 2022: we are allocating "many" large objects in the GPU memory and pytest does not give us access to a proper garbage collector, so the cupy driver fails deallocating memory. By reducing the memory the deallocation is faster and the pytest loop (allocation/deallocation) works.

I have also fixed a missing casting in samples_to_decimal, supposing that we want to keep the operation on CPU, otherwise pytest will raise:

FAILED tests/test_measurements.py::test_circuit_copy_with_measurements[qibojit-cupy-None] - TypeError: Argument 'array' has incorrect type (expected cupy._core.core._ndarray_base, got numpy.ndarray)
FAILED tests/test_measurements.py::test_circuit_copy_with_measurements[qibojit-cupy-accelerators1] - TypeError: Argument 'array' has incorrect type (expected cupy._core.core._ndarray_base, got numpy.ndarray)
FAILED tests/test_measurements.py::test_circuit_copy_with_measurements[qibojit-cupy-accelerators2] - TypeError: Argument 'array' has incorrect type (expected cupy._core.core._ndarray_base, got numpy.ndarray)
FAILED tests/test_measurements.py::test_circuit_copy_with_measurements[qibojit-cupy-accelerators3] - TypeError: Argument 'array' has incorrect type (expected cupy._core.core._ndarray_base, got numpy.ndarray)

Please let me know if you agree.

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2f89525) 100.00% compared to head (19adef4) 100.00%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1147   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           67        67           
  Lines         9589      9588    -1     
=========================================
- Hits          9589      9588    -1     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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.

@scarrazza scarrazza self-assigned this Dec 21, 2023
@scarrazza scarrazza added this to the Qibo 0.2.4 milestone Dec 21, 2023
@scarrazza scarrazza enabled auto-merge December 21, 2023 18:35
Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

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

Thank you for the fixes. Tests are now passing on my computer and the cluster.

@scarrazza scarrazza added this pull request to the merge queue Dec 26, 2023
Merged via the queue into master with commit 0eeb6ae Dec 26, 2023
21 checks passed
@stavros11 stavros11 deleted the fixcupy branch December 26, 2023 19:31
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.

cupy tests failing for some GPUs
3 participants