GithubHelp home page GithubHelp logo

Comments (10)

josevalim avatar josevalim commented on August 17, 2024

That's definitely weird, it should be zero copy. Can you confirm that calling Enum.map(df.names, fn name -> df[name] end) does not cause a big impact on memory? And then what about Enum.map(df.names, fn name -> Series.to_tensor(df[name]) end)? Those should all be light weight references.

from explorer.

billylanchantin avatar billylanchantin commented on August 17, 2024

@josevalim Yeah both are pretty instant.

That's definitely weird, it should be zero copy.

In this case I do expect some churn. Polars is a column store, and Nx.stack with axis: 1 is effectively doing a transpose.

from explorer.

josevalim avatar josevalim commented on August 17, 2024

Which backend are you using? EXLA or BinaryBackend?

from explorer.

josevalim avatar josevalim commented on August 17, 2024

Also, can you try Nx.concatenate instead of stack? I just want to rule something out quickly.

from explorer.

billylanchantin avatar billylanchantin commented on August 17, 2024

BinaryBackend, unfortunately :(

My intention is to pass this to EXGBoost.train, but EXGBoost has some issues with non-binary backends.

I've tried using the EXLA backend -> serializing -> deserializing but that didn't work. (There were many steps to the process so I might've messed something up.)

from explorer.

billylanchantin avatar billylanchantin commented on August 17, 2024

Oh sorry missed your earlier message.

Also, can you try Nx.concatenate instead of stack? I just want to rule something out quickly.

Will do. I'm already trying this in the background to see if it's Nx or Explorer:

transposed = Nx.stack(df) # worked pretty much instantly
Nx.transpose(transposed)  # currently working hard...

Will try your thing once it's done.

from explorer.

josevalim avatar josevalim commented on August 17, 2024

In any case, I think we should make Nx.stack a default callback, so when invoked for EXLA, it does not perform several copies. I will open up a separate issue.

from explorer.

billylanchantin avatar billylanchantin commented on August 17, 2024

Nx.transpose(transposed) OOM'd.

Nx.concatenate(df) succeeded pretty quickly (though it has shape {1_909_672_222}). Did you want me to pass any options to Nx.concatenate/2?

from explorer.

josevalim avatar josevalim commented on August 17, 2024

I guess we can close this. We have optimized concatenate in Nx for the default backend and there is an open issue to optimize stack too.

from explorer.

billylanchantin avatar billylanchantin commented on August 17, 2024

Agreed!

For posterity, these additions to Nx made stack(..., axis: 1) no longer OOM and take 3.5 mins on my VM:

My work around was taking ~11.5 min, so this is a great improvement.

Further improvements should come from addressing this issue:

from explorer.

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.