question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indexing multidim array causes massive slowdown in Jax 0.2.28

See original GitHub issue

On Jax version 0.2.28: (doesn’t reproduce on i.e. 0.2.15) The following code runs extremely slow:

import jax
import jax.numpy as jnp
import time

def tester(carry, unused):
    selection = jnp.arange(1000)
    selected = carry[:, selection, ...]
    return carry, selected[0,0,0,0,0]
size = 8
starter = jnp.ones((10,2000,size,size,4))
start_time = time.time()
for i in range(200):
    print("time", time.time() - start_time) # 4+ seconds each iteration
    starter, _ = tester(starter, ())

Curiously: changing size to 7 makes the loop fast again (<< 1s per iteration, as in 0.2.15). Any idea what’s going on here?

Replicated across TPU sizes colab, v2-8 and v3-8.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hawkinspcommented, Feb 16, 2022

Thanks for the report, I agree this is much slower than it should be. I filed a bug against the TPU compiler folks (Google bug b/219921462).

0reactions
bycncommented, Mar 4, 2022

@hawkinsp thanks for the fix but — how can I get that version to work? I tried to do pip install "jax[tpu]" -f http:/... -U , but this gives me 01/28 version, so according to https://github.com/google/jax/issues/9220 I tried to upgrade just the nightly with pip install --upgrade libtpu-nightly -f https://storage.googleapis.com/jax-releases/libtpu_releases.html but import crashes on TPUVM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to speed up indexing a vector with JAX?
I am indexing vectors and using JAX, but I have noticed a considerable slow-down compared to numpy when simply indexing arrays.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found