Skip to content

functorch -> torch.func (as of PyTorch 2.0)

Latest
Compare
Choose a tag to compare
@zou3519 zou3519 released this 17 Mar 17:10
feed934

As of PyTorch 2.0, we have deprecated the functorch module in favor of the new torch.func module in PyTorch.

functorch started as an out-of-tree library here at the pytorch/functorch repository. Our goal has always been to upstream functorch directly into PyTorch and provide it as a core PyTorch library.

As the final step of the upstream, we’ve decided to migrate from being a top level package (functorch) to being a part of PyTorch to reflect how the function transforms are integrated directly into PyTorch core. As of PyTorch 2.0, we are deprecating import functorch and ask that users migrate to the newest APIs, which we will maintain going forward. import functorch will be kept around to maintain backwards compatibility for at least one year.

Please see https://pytorch.org/docs/2.0/func.migrating.html for a full guide to the migration. The TL;DR is that:

  • our function transform API has not changed
  • we've changed how the functional NN module API works to better fit into PyTorch
  • AOTAutograd is still alive and well, but should not be used as a frontend for compilation. PyTorch has consolidated on torch.compile as the frontend compilation API.

We'll continue to publish functorch binaries on pypi as well to maintain backwards compatibility, but note that as of PyTorch 1.13, installing PyTorch will automatically allow you to import functorch.