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

Ensure PyTorch cuda compatability #21

Merged
merged 1 commit into from
Aug 21, 2023
Merged

Ensure PyTorch cuda compatability #21

merged 1 commit into from
Aug 21, 2023

Conversation

gpleiss
Copy link
Collaborator

@gpleiss gpleiss commented Aug 21, 2023

Previously, many arrays were being created without specifying the device. This omission caused device errors when using CoLA with PyTorch and cuda.

This PR adds the device kwargs to all uses of the following xnp methods:

  • zeros
  • ones
  • array
  • canonical
  • eye

Previously, many arrays were being created without specifying the
device. This omission caused device errors when using CoLA with PyTorch
and cuda.

This PR adds the device kwargs to all uses of the following xnp methods:
- zeros
- ones
- array
- canonical
- eye
@@ -121,7 +121,7 @@ def lu_solve(a, b):


def get_device(array):
if not isinstance(array, jax.core.Tracer):
if not isinstance(array, jax.core.Tracer) and hasattr(array, 'device'):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this second check because, at least in the tests, the Jax xnp seems to be used with numpy arrays which do not have a device attribute.

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #21 (505f471) into main (91ce584) will increase coverage by 0.07%.
The diff coverage is 95.31%.

@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
+ Coverage   81.93%   82.00%   +0.07%     
==========================================
  Files          39       39              
  Lines        3277     3290      +13     
==========================================
+ Hits         2685     2698      +13     
  Misses        592      592              
Files Changed Coverage Δ
cola/algorithms/preconditioners.py 100.00% <ø> (ø)
cola/linalg/diag_trace.py 80.55% <0.00%> (ø)
cola/linalg/eigs.py 91.37% <ø> (ø)
cola/ops/operator_base.py 83.79% <ø> (ø)
cola/algorithms/arnoldi.py 99.33% <100.00%> (+0.01%) ⬆️
cola/algorithms/cg.py 98.51% <100.00%> (+0.05%) ⬆️
cola/algorithms/diagonal_estimation.py 76.66% <100.00%> (ø)
cola/algorithms/gmres.py 93.75% <100.00%> (+0.16%) ⬆️
cola/algorithms/iram.py 100.00% <100.00%> (ø)
cola/algorithms/lanczos.py 100.00% <100.00%> (ø)
... and 4 more

@AndPotap AndPotap merged commit 00be7b1 into main Aug 21, 2023
4 checks passed
@AndPotap AndPotap deleted the pytorch_cuda branch August 24, 2023 02:01
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