Giter Site home page Giter Site logo

Comments (7)

zou3519 avatar zou3519 commented on August 16, 2024 1

Fixed by pytorch/pytorch#61458

from functorch.

zou3519 avatar zou3519 commented on August 16, 2024

The output looks like this:

def forward(self, value_1):
    _tensor_constant0 = self._tensor_constant0
    copy_ = torch.ops.aten.copy_(_tensor_constant0, value_1, False);  _tensor_constant0 = value_1 = None
    _tensor_constant1 = self._tensor_constant1
    return _tensor_constant1

from functorch.

zou3519 avatar zou3519 commented on August 16, 2024

So the issue is:

Some possible solutions, in no particular order:

  1. have at::empty trace back into FX
  2. (in pytorch/pytorch) make Tensor::to a primitive w.r.t. autograd. That is, write a backward formula for it. This will make Tensor::to show up in the graph and so whoever is working with the IR doesn't have to deal with an at::empty and then a Tensor::copy_
  3. Have functorch have its own set of primitives for autograd. We could declare and define a new operator functorch::to and have DynamicLayerFrontMode always transform aten::to into functorch::to, much like how we're transforming aten::new_zeros into functorch::new_zeros

from functorch.

zou3519 avatar zou3519 commented on August 16, 2024

There seems to be a general problem that operations that pass through autograd decompose into difficult-to-transform code. #42 is pretty similar.

from functorch.

Chillee avatar Chillee commented on August 16, 2024

Is transforming aten::<x> into functorch::<x> a feasible solution for all these cases?

from functorch.

zou3519 avatar zou3519 commented on August 16, 2024

If we go down that route we need a way to actually add autograd support to e.g.functorch::to so that it doesn't get decomposed into its constituents. The way that one does autograd support out of tree is by using torch::autograd::Function. There is a TODO item to check that this actually works; if it works then I think it'll be feasible but I'm worried that torch::autograd::Function doesn't compose with the dynamic layer stack.

from functorch.

zou3519 avatar zou3519 commented on August 16, 2024

pytorch/pytorch#61458 will probably fix this

from functorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.