Registry / ai-ml / jmp
library0.0.4pypypiunverified

JMP is a Python library from DeepMind that provides abstractions for mixed precision training in JAX. It enables the use of full and half-precision floating-point numbers during model training to reduce memory bandwidth and improve computational efficiency. It is currently at version 0.0.4 and sees active development with new releases addressing JAX compatibility and feature enhancements.

pip install jmp
INSTALL
IMPORT
SIG · JMP
J
jmp
ai-mlpythonv0.0.4
Install
3.6s avg
Import
Disk
89MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 89.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.6s · import 0.000s · 86MB
89MB installed
● package 89MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jmp
import jmp
import jmp

This quickstart demonstrates how to define a mixed precision policy using `jmp.Policy` and apply it to JAX arrays. It also shows the basic usage of `jmp.DynamicLossScale` for adjusting the loss scale during training based on gradient finiteness.

import jax import jax.numpy as jnp import jmp # Define floating point types based on your hardware (e.g., bfloat16 for TPU, float16 for GPU) half = jnp.float16 # or jnp.bfloat16 for TPUs full = jnp.float32 # Create a mixed precision policy # Parameters stored in full precision, computation and output in half precision policy = jmp.Policy(param_dtype=full, compute_dtype=half, output_dtype=half) # Example: Applying policy to a JAX array x = jnp.array([1.0, 2.0, 3.0], dtype=full) x_half = policy.cast_to_compute(x) print(f"Original (full): {x.dtype}, {x}") print(f"Computed (half): {x_half.dtype}, {x_half}") # Example: Using DynamicLossScale # Initialize DynamicLossScale with an initial loss scale value loss_scale = jmp.DynamicLossScale(jmp.half_dtype()(2**15)) # Using a jmp dtype helper # Simulate a gradient check and adjustment grads_finite = True # Assume gradients were finite in this step loss_scale = loss_scale.adjust(grads_finite) print(f"Adjusted loss scale: {loss_scale.loss_scale}")
Debug
Known issues
breakingJMP v0.0.3 dropped support for Python 3.7. Users on Python 3.7 must upgrade their Python version to use v0.0.3 or newer.
fix
Upgrade Python to 3.8 or newer. The current recommended minimum Python version is 3.8.
affects: >=0.0.3
gotchaJMP relies on JAX, which has specific installation instructions depending on your desired accelerator (CPU, GPU, TPU). JMP does not list JAX as a direct dependency in its `requirements.txt` to avoid conflicts. You must install JAX separately *before* installing JMP.
fix
Follow JAX's official installation guide (e.g., `pip install jax[cuda12_pip]` for CUDA 12) before running `pip install jmp`.
affects: All
gotcha`DynamicLossScale` might warn if non-floating point types are passed where floating types are expected. While JMP v0.0.4 includes fixes to avoid triggering certain warnings, ensuring correct dtype usage is crucial for stable mixed precision training.
fix
Ensure that inputs to `DynamicLossScale` and related functions are of appropriate floating-point dtypes (e.g., `jnp.float16`, `jnp.bfloat16`, `jnp.float32`). Use `jmp.half_dtype()` or `jmp.full_dtype()` for clarity.
affects: All
Upgrade
Version history
0.0.4latest on PyPI · released Jan 30, 2023
Audit
Dependencies
jaxrequiredCore dependency for numerical computation. Must be installed separately to choose correct accelerator version.
numpyrequiredUsed by JAX internally and for array handling.
Agent activity
20 hits · last 30 days
node
20
Resources
jmp — pip install jmp · libregistry