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

Adding torch implementation #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oselin
Copy link

@oselin oselin commented Jan 29, 2024

Added torch implementation of JVP, via the extension of torch.autograd capabilities

@oselin
Copy link
Author

oselin commented Jan 29, 2024

This pull request solves issue #1

@elcorto elcorto self-assigned this Feb 1, 2024
@elcorto elcorto self-requested a review February 1, 2024 23:16
Copy link
Member

@elcorto elcorto 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 very much for this PR.

The code seems to be copied from a larger application code base and adds a number of application-specific functions that may distract users from focusing on the essential autodiff bits. Also there is a module control which is not part of the PR, so the script doesn't run.

I think it will not be helpful to provide this module and possibly more code to make the example run.

Instead, I propose to re-implement (a subset of) what test_jax.py does, such as a custom derivative for a sin(), as is shown with mysin() and mycos() there, as a minimal example of how to use torch's API for defining custom derivs.

Further, the existing code in test_torch.py is instructive in that it shows how the torch API exposes reverse mode autodiff. It should therefore probably be kept, rather than replaced. A minimal custom deriv example could instead be added as an additional test case in test(), with supporting functions / classes defined above.

Side note, unrelated to the PR itself: Since you implement your custom derivs with central diffs, maybe a dedicated library such as https://github.com/pbrod/numdifftools or https://github.com/maroba/findiff could be of help.

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