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

simple functorch with modes #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

simple functorch with modes #40

wants to merge 1 commit into from

Conversation

samdow
Copy link
Collaborator

@samdow samdow commented Jun 14, 2022

This adds a rewrite of the simple functorch notebook to use torch dispatch modes. In doing this, we needed to add padding to vmap (i.e. we need to make vmap(f)(torch.randn(2), torch.randn(2, 4)) work)

Still TODO:

It raised a couple bugs in torch dispatch modes

  • fix bug to set ancestors if inner is explicitly given
  • fix bug to make enable_torch_dispatch_mode(None, replace=True) work


from torch.utils._mode_utils import no_dispatch

class Autograd(Dispatcher):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that because we're sitting at the torch dispatch level, autograd has already happened so we still have to rewrite autograd here and can't reuse PyTorch's autograd. This would be a no-go in actual functorch so we'll need to figure out a solution here

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.

1 participant