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

Adjoint operations move Jacobian from GPU to CPU #88

Closed
yashsavani opened this issue Mar 20, 2024 · 1 comment
Closed

Adjoint operations move Jacobian from GPU to CPU #88

yashsavani opened this issue Mar 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@yashsavani
Copy link

🐛 Bug

The adjoint operations in CoLA are moving the Jacobian tensor from the GPU to the CPU, which can lead to performance issues and inconsistencies.

To reproduce

** Code snippet to reproduce **

import torch
import cola

dev = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

x = torch.randn(100).to(dev)
fn = torch.nn.Sequential(torch.nn.Linear(100, 64), torch.nn.Linear(64, 100)).to(dev)

J = cola.ops.Jacobian(fn, x)
print(J.device, J.T.device, J.H.device, cola.ops.Adjoint(J).device)

** Stack trace/error message **

cuda:0 cpu cpu cpu

Expected Behavior

Output should look like:

cuda:0 cuda:0 cuda:0 cuda:0

System information

Please complete the following information:

  • 0.0.6.dev11+gf3c5494
  • 2.1.2
  • Springdale Open Enterprise Linux 8.6 (Modena)

Additional context

Possibly an issue here
https://github.com/wilson-labs/cola/blob/main/cola/ops/operators.py#L361
where the device is not being used

@yashsavani yashsavani added the bug Something isn't working label Mar 20, 2024
@AndPotap
Copy link
Collaborator

Thank you for pointing out this bad allocation of devices. Also thank you for the concise and well though code snippet to reproduce. I've just added a fix on #97.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants