r/JAX • • Jun 12 '26

NumPy vs. JAX for 2D CFD: Side-by-side performance and frame-rate comparison on identical geometry.

69 Upvotes

JAX vs NumPy CFD performance comparison: llaminar flow benchmark 🦙

I wanted to compare how JAX and NumPy behave on a simple CFD-style advection setup using the same geometry and flow conditions, focusing on execution speed and temporal evolution.

The setup is intentionally minimal:

  • Domain: 2D laminar flow around a fixed obstacle (identical mesh, boundary conditions, and geometry)

  • Solver: Same numerical scheme implemented in both backends

  • Parameters: Identical initial conditions and time step

  • Difference: Standard CPU NumPy (eager execution) vs JAX with @jit compilation

The video shows both simulations side-by-side with a synchronized start.

The visualization tracks the scalar field evolution around the obstacle and the resulting wake development.

Results

  • NumPy: ~5 FPS, with noticeably slower update cadence

  • JAX: ~117 FPS, enabling much smoother real-time evolution

  • Numerical behaviour: Both implementations produce equivalent flow evolution for the tested configuration

This is not a comparison of solver accuracy or turbulence models. It is a comparison of execution models and how backend performance affects the experience of running time-dependent PDE simulations.


r/JAX • • Apr 29 '26

Replacing the Pressure Poisson Solve with a Neural Operator in a JAX CFD Solver

42 Upvotes

I'm experimenting with replacing the pressure Poisson solve inside a differentiable incompressible CFD solver in JAX (AeroJAX).

Baseline projection step:

u* = advection-diffusion
∇²p = div(u*) / dt
u = u* - dt ∇p

Instead of solving the Poisson equation iteratively (multigrid / CG), I swap it with a small neural operator (3-layer CNN in Equinox) that predicts pressure in a single forward pass each timestep.

So:

  • classical: iterative Poisson solve

  • AeroJAX: learned forward operator

Why JAX matters here is simple: the whole pipeline is already differentiable and composable, so the pressure solve is just another interchangeable function inside the same JIT-compiled graph.

What I see so far:

  • faster than multigrid

  • stable in bulk flow

  • clear loss of mass conservation in wake / boundary regions

  • needs strong regularization (low init scale + pressure clipping)

Still early, but interesting how far operator replacement can go before physics constraints dominate again.

code: https://github.com/arriemeijer-creator/AeroJAX


r/JAX • • Apr 07 '26

I built a differentiable CFD solver in JAX. No ML yet. But the hard part (autodiff through Navier-Stokes) is done.

30 Upvotes

r/JAX • • May 27 '13

[Pic] Here is a picture of my house.

Post image
24 Upvotes

r/JAX • • Sep 03 '13

Hi Jax. I <3 <3 <3 your site.

Post image
22 Upvotes

r/JAX • • Nov 24 '24

Try the new Flax NNX API!

Post image
18 Upvotes

r/JAX • • May 10 '26

Parax v0.7: Parametric Modeling in JAX

17 Upvotes

Hi everyone!

Parax is a library for "Parametric modeling" in JAX, attempting to bridge the gap between pure JAX PyTrees, and more object-orientated modeling approaches (e.g. using Equinox) when it comes to needing rich parameter structures.

v0.7 has been released, featuring a more polished API as well as some detailed examples in the documentation.

Some of Parax's features:

  • Derived/constrained parameters with metadata

  • Computed PyTrees and callable parameterizations

  • Abstract interfaces for fixed, bounded, and probabilistic PyTrees and parameters

Two new examples in the docs that show off these features

Perhaps the library is of use to someone, and feel free to leave any feedback!

Cheers,
Gary


r/JAX • • Mar 24 '25

Learning resources for better concepts of JAX

17 Upvotes

Hi,

I have been using JAX for a year now. I have taken command over JAX syntax, errors, and APIs but still feel a lack of deep understanding. I face a lot of challenges when optimizing for memory and to me the problem is in my concepts. How can I make these concepts stronger, any tips or learning resources?

Thank you


r/JAX • • May 13 '13

[Pic] Public School #4 in Riverside.

Post image
17 Upvotes

r/JAX • • Sep 27 '13

Look what I found today! [Pic]

Post image
16 Upvotes

r/JAX • • May 17 '25

Xtructure: JAX-Optimized Data Structures (Batched PQ & Hash Table, for now)

15 Upvotes

Hi!

I've got this thing called Xtructure that I've been tinkering with. It's a Python package with some JAX-optimized data structures. If you need fast, GPU-friendly stuff, maybe check it out.

My other project, JAxtar (https://github.com/tinker495/JAxtar), was shared here a while back. Xtructure was basically born out of JAxtar, and its data structures are already battle-tested there, effectively powering searches through state spaces with trillions of potential states!

So, what's in Xtructure?

  • Batched GPU Priority Queue (BGPQ): Handy for managing priorities efficiently right on the GPU.

  • Cuckoo Hash Table (HashTable): A speedy hash table that's all JAX-native.

And I'm planning to add more data structures down the line as needed, so stay tuned for those!

The Gist:

You can define your own data types with xtructure_dataclass and FieldDescriptor, then just use 'em with BGPQ and HashTable. They're made to work nicely with JAX's compile magic and all that.

Why bother?

  • Avoid the Headache: Implementing a robust Priority Queue or Hash Table in pure JAX that actually performs well can be surprisingly tricky. Xtructure aims to do the heavy lifting.

  • PyTree Power with Array-like Handling: Define complex PyTrees with xtructure_dataclass and then index, slice, and manipulate them almost like you would a regular jax.numpy.array. Super convenient!

  • JAX-Native: It's built for JAX, so it should play nice with jit, vmap, etc.

  • GPU-Friendly: This is designed for efficient GPU execution.

  • Make it Your Own: Define your data layouts how you want.

https://github.com/tinker495/Xtructure

Would be cool if you checked it out. Let me know if it's useful or if you hit any snags. Feedback's always welcome!


r/JAX • • Nov 25 '24

Project: New JAX Framework that lets you do Functional Style for neural nets and more

15 Upvotes

I liked JAX both for its approach (FP) then for its speed. It was a little sad for me when i had to sacrifice the FP style with OO + transform (flax/haiku) or use callable objects (eqx).

I wanted to share with you a little library a wrote recently on my spare time. It’s called zephyr(link in comments) and it is built on top jax. You write in an FP style, you call models which are functions (not callable objects, if you ignore that in python type(function) is object).

It’s not perfect, like the lack of examples aside from the README, or a lack of RNN (havent had time yet). But i’m able to use it and am using it. I found it simple, everything is a function.

I hope you can take a look and hear some comments on how I can improve it! Thanks!


r/JAX • • Aug 25 '13

The Jags Almost Won! [Pic]

Post image
15 Upvotes

r/JAX • • May 12 '13

[Pic] Happy Mothers Day!

Post image
15 Upvotes

r/JAX • • Jun 26 '11

Hey everyone! If you were at the meetup, check out this photo and let me know which number you are, so we can provide your usernames to the powers that be. Also check out the rest of the set. :)

Thumbnail
flickr.com
15 Upvotes

r/JAX • • Apr 27 '23

Introducing NNX: Neural Networks for JAX

14 Upvotes

Can we have the power of Flax with the simplicity of Equinox?

NNX is a highly experimental 🧪 proof of concept framework that provides Pytree Modules with:

  • Shared state

  • Tractable mutability

  • Semantic partitioning (collections)

Defining Modules is very similar to Equinox, but you mark parameters with nnx.param, this creates some Refx references under the hood. Similar to flax, you use make_rng to request RNG keys which you seed during init.

NNX introduces the concept of Stateful Transformations, these track the state of the input during the transformation and update the references on the outside.

Notice in the example there's no return 🫢

If this is too much magic, NNX also has Filtered Transforms which just pass the references through the underlying JAX transforms but don't track the state of the inputs.

Return here is necessary.

Probably the most important feature it introduces is the ability to have shared state for Pytree Module. In the next example, the shared Linear layer would usually loose its shared identity due to JAX's referential transparency. However, Refx references allow the following example to work as expected:

If you want to play around with NNX check out the Github repo, it contains more information about the design of the library and some examples.
https://github.com/cgarciae/nnx

As I said in the beginning, for the time being this framework is a proof of concept, its main goal is to inspire other JAX libraries, but I'll try to continue development while makes sense.


r/JAX • • Feb 17 '21

IMAX: Image augmentation library for Jax

14 Upvotes

Made an image augmentation library in Jax that is able to do 3D transforms and many color transforms present in Pillow and even has a randaugment function. Happy about any kind of feedback. github, pypi


r/JAX • • Aug 21 '13

Jax Wizard [Pic]

Post image
14 Upvotes

r/JAX • • Aug 13 '13

Hey Jax. What say you about this? -- EXCLUSIVE: Owner of Snowden’s Email Service on Why He Closed Lavabit Rather Than Comply With Gov’t [Pol]

Thumbnail
democracynow.org
14 Upvotes

r/JAX • • May 20 '13

[Pic] Gateway Town Center - The Loneliest Mall!

Thumbnail
imgur.com
14 Upvotes

r/JAX • • May 08 '13

[Pic/Pol] One in how many people are incarcerated? State by state:

Post image
14 Upvotes

r/JAX • • Apr 28 '26

3D interactive map of the JAX (Google) ecosystem (auto-refreshed weekly)

13 Upvotes

Built JAXlaxy observatory - every library in the JAX awesome-list as a glowing star in a 3D galaxy where color = health status (active/stable/legacy), spatial cluster = which "constellation" (Core, Giants, Satellites, etc.) it belongs to.

🌌Live: https://jaxlaxy.bryanbradfo.me

📦Source: https://github.com/BryanBradfo/JAXlaxy (MIT)

Navigating JAX ecosystem from a flat README isn't great for spatial questions like "what's the active landscape for LLM training right now?" or "which probabilistic programming libraries are still maintained?" The 3D map is meant for that kind of exploration.

Two things I'd love feedback on:

  1. Spatial clustering: currently Fibonacci-sphere anchors with Gaussian density per cluster. Other approaches I considered: spiral arms, orbital rings. Open to ideas if anyone has stronger intuitions for what "feels right" for an ecosystem map.

  2. 75-entry ceiling: README is deliberately curated, not exhaustive. The bar is roughly "JAX-native + actively maintained or meaningfully Legacy + adds something distinct to the ecosystem." If you think a repo deserves a spot (or that something currently included doesn't deserve one), I'd rather have the editorial debate than just add things mechanically. PRs that argue the case in their description are exactly the input I want.


r/JAX • • Jan 02 '20

The "I love living in Jacksonville" video that's not allowed in some other Jacksonville subreddit...

Thumbnail
youtu.be
13 Upvotes

r/JAX • • Aug 24 '14

Alvin Brown is on the list of Mayors that are in Comcast's pocket. [Pol]

Thumbnail
dailydot.com
13 Upvotes

r/JAX • • Jul 23 '13

The fireworks in Jacksonville are AMAZING! Truly beautiful. [Pic]

Post image
13 Upvotes