GithubHelp home page GithubHelp logo

Comments (6)

py4 avatar py4 commented on June 7, 2024 1

@froystig nice! it worked

image

from jax.

jakevdp avatar jakevdp commented on June 7, 2024

Have you tried it under jit?

from jax.

py4 avatar py4 commented on June 7, 2024

@jakevdp yeah same result:

import jax
import jax.numpy as jnp

@jax.jit
def get_random_array(key):
    return jax.random.uniform(key, (524288, 4096), dtype=jnp.bfloat16, minval=-1, maxval=1)

if __name__ == "__main__":
    key = jax.random.key(0)
    jax.profiler.start_trace("/tmp/profile/tmp")
    arr = get_random_array(key)
    arr.block_until_ready()
    jax.profiler.stop_trace()

image

from jax.

froystig avatar froystig commented on June 7, 2024

What RNG implementation are you using? If it's the default (threefry), have you tried using it in "partitionable" mode? You can do that by adding the line:

jax.config.update('jax_threefry_partitionable', True)

at the top of your file.

#18480 has more details (and other ways to set the option).

I ask because partitionable Threefry mode often involves fewer reshapes and stacking.

from jax.

py4 avatar py4 commented on June 7, 2024

@froystig the original issue is resolved, however FYI, the context manager seems not to be working (the memory issue apears with context manager, but not with jax.config.update('jax_threefry_partitionable', True) at top:

import jax
import jax.numpy as jnp

@jax.jit
def get_random_array(key):
    with jax.threefry_partitionable(True):
        return jax.random.uniform(key, (524288, 4096), dtype=jnp.bfloat16, minval=-1, maxval=1)

if __name__ == "__main__":
    key = jax.random.key(0)
    jax.profiler.start_trace("/tmp/profile/tmp")
    arr = get_random_array(key)
    arr.block_until_ready()
    jax.profiler.stop_trace()

from jax.

froystig avatar froystig commented on June 7, 2024

Thanks! Minimized and filed as #21061.

from jax.

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.