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

torch.func (pytorch 2.0) compatibility #98

Open
fzimmermann89 opened this issue May 28, 2024 · 1 comment
Open

torch.func (pytorch 2.0) compatibility #98

fzimmermann89 opened this issue May 28, 2024 · 1 comment

Comments

@fzimmermann89
Copy link

Hi,

to be able to use torch.func.* (for example, torch.func.grad) with torchkbnufft, the torch.autograd.Functions in torchkbnufft/_autograd/interp.py would need an update to the newer calling signature.
See https://pytorch.org/docs/stable/notes/extending.func.html.

In particular, the forward should no longer take a ctx argument. Instead, it should return the output and all tensors etc. that need to be saved to ctx. And a third function, setup_context should save it in ctx.
Also, it would be nice to make use of vmap possible

As this would break compatibility for pytorch versions <2.0 (released before March 2023), this would either require a new torchkbnufft version and a bump in the required torch version, or an import-time switch depending on the pytorch version.

I would be willing to prepare a PR for either option.

@mmuckley
Copy link
Owner

Hello @fzimmermann89, this would be a very welcome contribution! Feel free to file a PR for this.

I think we can make a new version of torchkbnufft and require the newer PyTorch. I'm not a big fan of import switching.

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

No branches or pull requests

2 participants