Skip to content

Conversation

@xuanguang-li
Copy link
Contributor

@xuanguang-li xuanguang-li commented Oct 22, 2025

This pull request modernizes the markov_asset.md notebook by refactoring the codebase to use JAX and JAX NumPy.

  • Refactored all numerical computations and linear algebra from numpy and numpy.linalg to jax.numpy and jax.numpy.linalg.
  • Replaced the mutable AssetPriceModel class with an immutable, type-safe NamedTuple version and introduced a create_ap_model factory function for consistent construction.
  • Updated function signatures and internal logic to use the new model structure.
  • Replaced manual Python loops with JAX functional control flow constructs such as jax.lax.while_loop and jax.lax.fori_loop.
  • Fixed minor bugs in parameter initialization, state handling, and tolerance defaults.

Update: Runtime Comparison Between JAX (GPU), JAX (CPU), and NumPy

Methodology:

  • The JAX version uses the code in this PR, while the NumPy version uses the code in main.
  • The runtime for JAX (GPU) is measured using Google Colab.
  • Runtime is collected using qe.timeit over 1,000 iterations.
  • Each iteration consists of one function that solves the consol price and one that solves the call option price.

Results:

  • Average runtime: JAX (CPU) > NumPy > JAX (GPU).
  • More details are shown in the attached plots.
runtime_compare_average runtime_compare_boxplot

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (0317e4a)

📚 Changed Lecture Pages: harrison_kreps, markov_asset, two_auctions

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (76c64b2)

📚 Changed Lecture Pages: harrison_kreps, markov_asset, two_auctions

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (02dfe6e)

📚 Changed Lecture Pages: harrison_kreps, markov_asset, two_auctions

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (211ec24)

📚 Changed Lecture Pages: harrison_kreps, markov_asset, two_auctions

@xuanguang-li xuanguang-li marked this pull request as ready for review October 27, 2025 08:51
@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (cb2995a)

📚 Changed Lecture Pages: markov_asset

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (4adc2f5)

📚 Changed Lecture Pages: markov_asset

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

📖 Netlify Preview Ready!

Preview URL: https://pr-654--sunny-cactus-210e3e.netlify.app (e47f942)

📚 Changed Lecture Pages: markov_asset, markov_asset_numpy

@xuanguang-li xuanguang-li changed the title [markov_asset] Update to JAX [markov_asset] Update to JAX and runtime comparison Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants