Skip to content

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