Skip to content

Commit

Permalink
Update test_benchmark.py to use jax.block_until_ready for more accu…
Browse files Browse the repository at this point in the history
…rate measurement of computation time

For more info see https://jax.readthedocs.io/en/latest/async_dispatch.html#async-dispatch
  • Loading branch information
xela-95 committed Jan 15, 2025
1 parent df81dfa commit 709ceed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def benchmark_test_function(

# Warm-up call to avoid including compilation time
jax.vmap(func, in_axes=(None, 0))(model, data)
benchmark(jax.vmap(func, in_axes=(None, 0)), model, data)

# Benchmark the function call
# Note: jax.block_until_ready is used to ensure that the benchmark is not measuring only the asynchronous dispatch
benchmark(jax.block_until_ready(jax.vmap(func, in_axes=(None, 0))), model, data)


@pytest.mark.benchmark
Expand Down

0 comments on commit 709ceed

Please sign in to comment.