jax icon indicating copy to clipboard operation
jax copied to clipboard

Memory leak in OpenVINO JAX frontend (JaxprPythonDecoder) during model conversion

Open andersendsa opened this issue 7 months ago • 1 comments

Description

When converting JAX models using OpenVINO (ov.convert_model), memory usage increases linearly with the size of the model.

This is caused by a memory leak in OpenVINO's JAX frontend (src/bindings/python/src/openvino/frontend/jax/jaxpr_decoder.py). During visit_subgraph, the JaxprPythonDecoder stores all child decoders inside a standard Python list (self.m_decoders). Maintaining these strong Python references prevents the garbage collector from freeing the decoder objects once C++ is finished with them, resulting in significant memory bloat for large graphs.

import jax import jax.numpy as jnp import openvino as ov

def large_model(x): # Create a large graph to exacerbate the memory leak for _ in range(500): x = jax.nn.relu(x) + 1.0 return x

During conversion, OpenVINO's frontend will accumulate strong references

to hundreds of decoders in self.m_decoders, causing unbounded memory growth.

ov_model = ov.convert_model(large_model, example_input=jnp.ones((100, 100)))

System info (python version, jaxlib version, accelerator, etc.)

jax: 0.10.0 jaxlib: 0.10.0 numpy: 2.4.4 python: 3.12.13 (main, Mar 6 2026, 16:37:31) [GCC 13.3.0] device info: cpu-1, 1 local devices process_count: 1 platform: uname_result(system='Linux', node='devbox', release='6.8.0', version='#1 SMP PREEMPT_DYNAMIC Fri Feb 20 20:38:43 UTC 2026', machine='x86_64')

OpenVINO version: 2026.1.0-21367-63e31528c62

andersendsa avatar May 02 '26 06:05 andersendsa

Thanks, but I don’t think it makes sense to file this here. Looks like you have one open on openvino; that’s probably the right place.

mattjj avatar May 02 '26 06:05 mattjj