Git Product home page Git Product logo

Comments (6)

polvalente avatar polvalente commented on August 23, 2024

I believe this is an issue in Torchx itself and not in Axon. The Axon initializers are in the end all implemented through Defn, so if the backend options aren't being fetched and passed on properly, chances are this is related to Torchx.

An easy way to test this is to use EXLA in a machine with cuda support and set the default backend to {EXLA.Backend, client: :cuda}.

from axon.

alisinabh avatar alisinabh commented on August 23, 2024

Thanks @polvalente

I have investigated this issue a bit more and it seems like in the initiation process a tensor is being created using Nx.BinaryBacked and then this tensor get's passed to from_nx function in Torchx.Backend. Now based on torchx/backend.ex#L1808, Torchx will call Nx.backend_transfer but it does not know about the default options anymore and will create cpu tensor instead of mps or any other device that the user has specified.

I can see two possible solutions:

  1. Investigate why the initializer is making a tensor in Nx.BinaryBackend and force it to use Nx.default_backend instead.
  2. Create a new configuration parameter for Torchx which stores the default options for when the from_nx function wants to call backend_transfer(tensor, {Torchx.Backend, default_options}) in torchx/backend.ex#L1808

from axon.

benswift avatar benswift commented on August 23, 2024

I just ran into the same issue - did you ever try out either of your two proposed solutions?

from axon.

alisinabh avatar alisinabh commented on August 23, 2024

Hi @benswift

I actually changed a line in Torchex Backend to forcefully create tensors with the mps device for my test and it worked as expected.

But I don't yet understand why tensors are created in BinaryBackend in the first place...

from axon.

benswift avatar benswift commented on August 23, 2024

Ah, ok, thanks for the update :)

from axon.

josevalim avatar josevalim commented on August 23, 2024

Yes, this is a torchx issue, so closing for now!

from axon.

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.