Skip to content

About

Reproducible JAX correctness investigations: small upstream fixes, before/after CPU examples, and regression-test evidence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

JAX reliability notes

Reproducible investigations of JAX correctness and related Google AI infrastructure, by Jabrail Khalil.

I follow a small loop: calculate an independent expected result, reproduce the bug on upstream code, understand the transformation involved, and add a regression test before changing the implementation.

Case studies

Case User-visible problem Upstream contribution
Keyword forwarding A supplied loss coefficient is ignored; both the value and gradient are wrong. JAX #41156
Uneven collective groups A group mean uses another group's size; constant sums and gradients are also wrong. JAX #41157, closed as superseded by a maintainer fix
Generalized Hermitian eigenproblems A missing numerical API needs correct eigenvector transforms, normalization, and derivatives. JAX #41162, #41197
Finite meta-gradients through clipping (Русский) Zero updates have correct forward values but NaN reverse derivatives through a short optimizer loop. Optax #1815, merged
Concurrent Grain worker shutdown (Русский) Sequential child cleanup accumulates exit delays; parallel cleanup must preserve completion, error handling, and interpreter finalization. Grain #1430, open as of 12 October 2026
Lazy import scope isolation (Русский) A process-global import hook intercepts unrelated threads and GC finalizers and can leak named semaphores. etils #839, open as of 12 October 2026

As of 31 October 2026, keyword forwarding, both generalized-eigh contributions and the Optax clipping fix are merged. I closed the uneven-groups PR after Jake VanderPlas landed a maintainer-authored fix; my PR was not merged. The patch copies below demonstrate the original before/after investigations. Their checks used Linux CPU. The generalized-eigh lab uses a later source revision and was checked on Windows CPU. No accelerator execution is claimed for these labs.

Run the before/after examples

Use Python 3.12 and Git. These commands pin the upstream source so that a future upstream fix does not silently change the baseline.

git clone https://github.com/jabrailkhalil/jax-reliability-notes.git
cd jax-reliability-notes
python -m venv .venv

Activate the environment:

# Linux / macOS
source .venv/bin/activate
# Windows PowerShell
.\.venv\Scripts\Activate.ps1

Then, from the repository root:

git clone --filter=blob:none https://github.com/jax-ml/jax.git .lab/jax
git -C .lab/jax checkout 004eda6fcb36dd11d61ea9fa5fa2249a1810d604
python -m pip install -r requirements-demo.txt -e .lab/jax

python examples/keyword_forwarding.py --expect baseline
python examples/uneven_collectives.py --expect baseline

git -C .lab/jax apply ../../patches/keyword-forwarding.patch
git -C .lab/jax apply ../../patches/uneven-collectives.patch

python examples/keyword_forwarding.py --expect fixed
python examples/uneven_collectives.py --expect fixed

The examples print actual results alongside independently calculated references. --expect baseline succeeds only when the pinned bug is reproduced. --expect fixed succeeds only when all measured results match the references. An unexpected result exits with an error. The collective example configures four logical CPU devices before initializing JAX's backend; it does not require four physical CPUs or an accelerator.

The exact dependency environment used for validation was Python 3.12.14, jaxlib 0.11.2, NumPy 2.5.3, SciPy 1.18.1, and ml_dtypes 0.6.0. The source checkout above supplies JAX itself.

Test evidence

The validation directory contains the measured example output and complete relevant test-file logs. These are CPU checks; they do not replace upstream accelerator CI.

Contribution Before the fix After the fix Complete relevant test file, x64 off / on
Keyword forwarding 12 new regression scenarios fail 12 new scenarios pass api_test.py: 980 passed, 36 skipped / 983 passed, 37 skipped
Uneven groups 14 of 16 regression scenarios fail; 2 pass All 16 pass pmap_test.py: 289 passed, 31 skipped in each mode

Both submitted contributions passed JAX's complete pre-commit run --all-files checks, including Ruff and Pyrefly. The source checkpoints and commands are recorded in validation/results.json.

A short technical session

The 10-minute session outline turns these investigations into a practical walkthrough of testing numerical APIs. It is prepared material; no meetup delivery or audience impact is claimed here.

Shutdown correctness in Google ML infrastructure

The Russian Grain shutdown lab checks the actual close() method from pinned baseline and proposed-fix Git blobs without installing Grain's native dependencies. It reproduces exactly five baseline failures, requires twelve fixed checks to pass, and exercises real interpreter final GC separately from atexit. The fixtures isolate the cleanup protocol; native integration matrices and a controlled real-worker measurement are linked separately. This is self-study material, not a delivered workshop or a claim that the open PR is released.

The related etils import-scope lab uses the real installed package from exact revisions. It checks unrelated thread imports, GC finalizers, non-LIFO restoration, and native Linux named-semaphore cleanup. It credits mahdi-shafiei's original reproductions and proposed direction; the fix remains open for review.

Generalized eigenproblems in ML

In my Russian-language Fisher LDA article, I use the generalized eigh API to build a differentiable dimensionality-reduction example. I compare it with independent SciPy calculations, check jit and vmap, and verify gradients with finite differences. I include runnable code, measured CPU results, and a plot comparing PCA with regularized LDA on synthetic data. I have prepared the material for a lesson or workshop; I have not delivered it to an audience.

The English article and 45-minute hands-on worksheet (English / Русский) make the lab available for self-study and future community sessions. Both example modes were rerun successfully on Windows CPU on 3 October 2026. The worksheet includes independent-reference exercises and explicitly separates tested numerical behavior from unmeasured model quality or audience impact.

Agent context boundaries

The ADK Go context lab follows a user request through two sequential agents with local recording models. It compares the exact parent and accepted source of ADK Go #1895, including metadata-only events, retained payload signatures and unchanged stored history. One Python entry point runs the six scenarios and their negative controls without API keys. The material is independent of the ADK project and has not been delivered as a workshop.

Dataset comparison and label meaning

In this offline dataset-comparison lab, I compare explicit keyed rows, ClassLabel meanings, features and configuration separately. Identical data files can change label meaning; reordered shards can retain the same keyed content. The small synthetic fixtures, independent oracles and deliberately broken controls use the public Hugging Face Datasets APIs. This first slice has no Hub loader or model-quality benchmark.

Positional OCR review

In this positional OCR lab, I consume real OCRmyPDF OcrElement models to compare synthetic readings by page position, retain split/merged and ambiguous groups, and record explicit review choices. An independent four-region reference exposes an agreed-but-wrong reading missed by the disagreement queue. The example keeps that missed error in its denominator and preserves both original readings when recording a correction.

License

The educational material and examples are licensed under Apache-2.0. The patch excerpts modify JAX, which is also licensed under Apache-2.0; their upstream context remains copyright The JAX Authors. The clipping lab adapts Optax expressions, copyright DeepMind Technologies Limited, also under Apache-2.0. The shutdown lab loads pinned Grain source, copyright Google LLC, under the same license. The import-scope lab uses pinned etils, copyright The etils Authors, also under Apache-2.0. The ADK lab adapts the author-validation probe for Google ADK Go, copyright Google LLC, under Apache-2.0. See LICENSE and NOTICE.

About

Reproducible JAX correctness investigations: small upstream fixes, before/after CPU examples, and regression-test evidence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages