QuantEcon / lecture-jax

Lectures on Quantitative Economics Using JAX
https://jax.quantecon.org/
28 stars 4 forks source link

Not timing properly #163

Closed jstac closed 3 weeks ago

jstac commented 3 months ago

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:

shlff commented 3 months ago

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:

shlff commented 3 months ago

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.

jstac commented 3 months ago

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.

shlff commented 3 months ago

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