Giter Site home page Giter Site logo

Comments (6)

SunMarc avatar SunMarc commented on June 1, 2024 2

Hi @goelayu, this is expected since with torch.device('meta') also puts the buffers on the meta device. However, non persistant buffers are not saved in the state_dict. So, in the case of a llama model where we do have non persistant buffers, you get an error after loading the weights With init_empty_weights, by default, we don't put the buffer on the meta device. This is why it is working. Hope it is clearer !

from transformers.

ArthurZucker avatar ArthurZucker commented on June 1, 2024 1

cc @muellerzr for the accelerate related stuff rather than Sylvain!

from transformers.

goelayu avatar goelayu commented on June 1, 2024

To add to the above, if i use init_empty_weights from accelerate I can skip the initialization without any errors.

Wondering what is the difference between the two? Also if it is possible to achieve the same using the torch.device('meta') context manager.

from transformers.

ArthurZucker avatar ArthurZucker commented on June 1, 2024

Mmmm could you make sure that the map_location is correct?
This might be expected, cc @SunMarc WDYT?

from transformers.

goelayu avatar goelayu commented on June 1, 2024

So this issue seems to be documented in the code itself big_modeling.py, turns out you can't run model.to when using the meta device. I was hoping for some kind of explanation as to why is that the case?
(hence tagged @sgugger since the big_modeling.py file seems to be often modified by them)

Also if you notice my comment from above, replacing torch.device('meta') with init_empty_weights from the accelerate package seems to resolve the issue.

from transformers.

goelayu avatar goelayu commented on June 1, 2024

@SunMarc thanks for the response, that answers my question.

from transformers.

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.