Git Product home page Git Product logo

Comments (5)

anijain2305 avatar anijain2305 commented on June 29, 2024

cc @jansel @bdhirsh

from pytorch.

ezyang avatar ezyang commented on June 29, 2024

This is sort of like need proper subclass support in Dynamo :P

cc @mlazos

from pytorch.

laithsakka avatar laithsakka commented on June 29, 2024

I have a very simple repo
The first print(parameters) in the code changes the output from Parameter containing, to tensor with grad_fn

    def test_ParameterList(self):

        @torch.compile(backend="eager")
        def func():
            def make_param():
                return Parameter(torch.randn(2, 2))

            parameters = []
            # without the following print line we generate:
#             [Parameter containing:
#              tensor([[ 0.0461,  0.4024],
#              [-1.0115,  0.2167]], requires_grad=True)]
                    #
            # with it we geenrate 
# [tensor([[ 0.0461,  0.4024],
#         [-1.0115,  0.2167]], grad_fn=<TracableCreateParameterBackward>)]
            print(parameters)


            parameters.append(make_param())
            print(parameters)

        ```

from pytorch.

yf225 avatar yf225 commented on June 29, 2024

@laithsakka I wasn't able to repro using using the test_ParameterList example on nightly (it still prints Parameter containing: ...). Is it expected?

@anijain2305 I have seen this error before when working on Traceable FSDP+TP. Some thoughts:

  • The suggestion from error message (cloning the output) is not correct because we do want to preserve the nn.Parameter placeholder tensor identity (i.e. we must return the original nn.Parameter placeholder).
  • I wonder if you have high-level insight on why the nn.Parameter (or its base tensor) was mutated. I suspect it's from nn.Linear's reset_parameters method, but I haven't verified it myself yet.

from pytorch.

laithsakka avatar laithsakka commented on June 29, 2024

@yf225 sorry I updated the test I missed one print before parameters.append(make_param())

for the second print with the print we get

[tensor([[ 0.0461, 0.4024], [-1.0115, 0.2167]], grad_fn=)]

without it we get :

[Parameter containing:
tensor([[ 0.0461, 0.4024],
[-1.0115, 0.2167]], requires_grad=True)]

from pytorch.

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.