lecture-jax icon indicating copy to clipboard operation
lecture-jax copied to clipboard

Not timing properly

Open jstac opened this issue 10 months ago • 4 comments

In this lecture, when we do the timings, we do not use block_until_ready and we don't run twice to eliminate compile time.

https://jax.quantecon.org/opt_savings_1.html

I think this is probably true in a few other lectures.

We need a review of all timings, to make sure that we run twice, noting the time on both occasions, and that we block until ready.

Required actions:

  • [x] search for and list all lectures where we time JAX execution without block_until_ready
  • [x] insert block_until_ready as required
  • [x] check the timings of all lectures, particularly in dynamic programming, and make sure that we run executing twice, showing the timing with compile time and the timing without

jstac avatar Mar 27 '24 19:03 jstac

I did a thorough search: all Jax lectures except for mle have the issues of either not using block_until_ready or running twice to eliminate compilation time. (So I will not list them here)

Edit: given so many lectures, I list them here for tracking the modification progress:

  • [x] jax_intro
  • [x] newtons_method
  • [x] inventory_dynamics
  • [x] kesten_processes
  • [x] wealth_dynamics
  • [x] lucas_model
  • [x] markov_asset
  • [x] opt_savings_1
  • [x] opt_savings_2
  • [x] short_path
  • [x] opt_invest
  • [x] inventory_ssd
  • [x] ifp_egm
  • [x] cake_eating_numerical
  • [x] arellano
  • [x] aiyagari_jax
  • [x] ReEdit: check it again before review

shlff avatar Mar 30 '24 22:03 shlff

I spotted two extra issues during the searching:

  1. when we time the code, we use our timing methods tic/toc and Python time magic interchangeably in different lectures,
  2. we'd like to compare the timing of Jax code with our previous Numba code, but we do not eliminate the compilation time for Numba code

Regarding issue 1, I suggest we use our timing methods, tic/toc, for all Jax lectures.

Regarding issue 2, I suggest we also run the Numba code twice to eliminate the compilation.

shlff avatar Mar 30 '24 22:03 shlff

Thanks @shlff , these are good suggestions.

I suggest we use our timing methods, tic/toc, for all Jax lectures.

Actually I suggest that we use %time and %%time when possible --- unless we are recording the time to compare it to something later. If we are recording the time, let's use time.time(), since it's conventional in Python.

jstac avatar Mar 30 '24 22:03 jstac

Thanks for your comments @jstac . That's a better idea!

shlff avatar Mar 30 '24 23:03 shlff