Keras 3.16.0 was released on 3 December 2026. It’s a large release: the release notes count 638 pull requests from 108 contributors. The changes most likely to affect you are pluggable backends (OpenVINO has moved out of the main package), a new x64_mode setting that changes how 64-bit inputs behave on JAX, NumPy and PyTorch, and new ternary quantization with TernaryDense.
This guide covers those changes with examples. We installed keras==3.16.0 and ran the snippets on the NumPy and JAX backends to confirm the output.
Install
pip install --upgrade "keras==3.16.0"
# plus at least one backend, for example:
pip install "jax[cpu]"
The minimum PyTorch version is now 2.6.0, so upgrade PyTorch too if you use the torch backend.
Pluggable backends
Keras backends no longer have to live inside the keras package. A backend can ship as its own keras_<name> package and is loaded when KERAS_BACKEND names it. JAX, NumPy, TensorFlow and PyTorch remain built in.
Two backends use this right away:
- OpenVINO has moved to the separate
keras-team/keras-openvinoproject. - MLX is recognised through the
keras-mlxpackage.
Install them with the new extras:
pip install "keras[openvino]" # pulls in the matching 3.16.* backend package
pip install "keras[mlx]"
import os
os.environ["KERAS_BACKEND"] = "openvino" # set before importing keras
import keras
print(keras.backend.backend())
Breaking change: if you used the OpenVINO backend, plain pip install keras no longer includes it. Add keras[openvino] to your requirements.
If you’re developing a new backend, set KERAS_ALLOW_UNOFFICIAL_BACKEND=1 to load any keras_<name> package against a standard Keras install.
The x64_mode setting and the int64 change
This is the change most likely to break code without warning. On JAX, NumPy and PyTorch, 64-bit inputs are now treated as 32-bit by default. The notes give an example: an int64 tensor passed to an op gives an int32 result.
We confirmed this on the NumPy backend:
import os
os.environ["KERAS_BACKEND"] = "numpy"
import keras
from keras import ops
x = ops.ones((2,), "int64")
print(keras.config.x64_mode()) # off
print(ops.add(x, x).dtype) # int32
keras.config.set_x64_mode("explicit_x64")
print(ops.add(x, x).dtype) # int64
The three modes are:
"off": the default on JAX, NumPy and PyTorch. Results are capped to 32-bit."explicit_x64": the default, and only, mode on TensorFlow. A 64-bit input gives a 64-bit output, while 32-bit inputs, Python scalars and default dtypes stay 32-bit. On JAX it needs JAX 0.8.0 or newer."enable_x64": reserved and not supported yet.
Besides keras.config.set_x64_mode(), you can set the mode with the KERAS_X64_MODE environment variable or the "x64_mode" field in keras.json.
Who should care? Anyone with large integer IDs (user IDs, hashed features, timestamps in nanoseconds), or float64 maths that needs the precision. Silent truncation to 32-bit can cause overflow or wrong lookups. If that’s you, set explicit_x64 in your config file so every process uses it.
On JAX, set the mode before you create tensors. In our JAX test, an int64 tensor created under the default mode was already int32, so switching modes afterwards didn’t change the result. The notes also say Keras warns if you set JAX’s own 64-bit flags and they don’t match x64_mode.
Ternary quantization with TernaryDense
keras.layers.TernaryDense is a dense layer trained with weights limited to {-1, 0, +1}. After training, you can freeze it to packed ternary weights with layer.quantize("ternary").
import os
os.environ["KERAS_BACKEND"] = "jax"
import numpy as np
import keras
model = keras.Sequential([
keras.Input((8,)),
keras.layers.TernaryDense(16, activation="relu"),
keras.layers.Dense(3),
])
model.compile(
optimizer="adam",
loss=keras.losses.SparseCategoricalFocalCrossentropy(from_logits=True),
steps_per_execution=4,
jit_compile=True,
)
x = np.random.rand(64, 8).astype("float32")
y = np.random.randint(0, 3, 64)
model.fit(x, y, epochs=1, batch_size=16, verbose=0)
ternary = model.layers[0]
ternary.quantize("ternary")
print([w.dtype for w in ternary.weights]) # ['float32', 'uint8', 'float32']
print(model.predict(x[:2], verbose=0).shape) # (2, 3)
After quantize("ternary"), the kernel was stored as uint8 packed values. The model still predicted with the same output shape. The release also adds public helpers such as keras.quantizers.TernaryQuantizationConfig, QuantizationReport and pack_int2/unpack_int2/pack_ternary/unpack_ternary. GPTQ and AWQ were reworked, and model.quantize() is now “observable and fail-safe”.
The example above also uses two more 3.16 features:
SparseCategoricalFocalCrossentropy: a focal loss for integer labels, useful for imbalanced classes.steps_per_execution> 1: on JAX withjit_compile=True, Keras now runs groups of steps on the device withjax.lax.scan, with one host dispatch per group. The PyTorch backend now supportssteps_per_execution> 1 as well.
New ops
Keras 3.16 adds keras.ops.cov, matrix_power, column_stack, copysign, float_power, lgamma and gammainc, and an experimental keras.ops.grad on backends with automatic differentiation:
import numpy as np
from keras import ops
a = np.array([[1., 2.], [3., 4.]])
print(ops.matrix_power(a, 2)) # [[ 7. 10.] [15. 22.]]
print(ops.cov(np.array([[0., 1., 2.], [2., 1., 0.]]))) # [[ 1. -1.] [-1. 1.]]
print(type(ops.size(a)), ops.size(a)) # <class 'int'> 4
That last line shows another small change: keras.ops.size now returns a plain Python int on every backend.
Other breaking changes
Check these before upgrading:
.kerasarchives with NPZ weights no longer load, because the unsupportedmodel.weights.npzstorage was removed.- Integer inputs are now promoted to float in activations and maths ops such as
sigmoid,softmax,erfandrsqrt. - RNN layers no longer propagate masks automatically, which fixes a CTC loss dimension mismatch.
- Stricter argument validation now raises on invalid values, for example RMSprop
rho, BatchNormalizationmomentumand EarlyStoppingpatience. - On TensorFlow,
jit_compile=Trueunder a multi-replicatf.distributestrategy now warns and falls back tojit_compile=False.
Security and TensorFlow-free improvements
The release hardens loading: restricted unpickling for the IMDB, Reuters and CIFAR datasets, rejection of decompression bombs in .keras assets, and stricter checks when deserializing function configs. It also continues the work to make TensorFlow optional. Remote paths like gs:// work without TensorFlow through pip install "keras[gcs]", and the TensorBoard callback can write logs with tensorboardX when TensorFlow isn’t installed.
Takeaway
Keras 3.16 makes backends modular and quantization more capable, but the default 32-bit capping on JAX, NumPy and PyTorch deserves a careful test before you upgrade production pipelines. Pin x64_mode explicitly if you rely on 64-bit integers, add keras[openvino] if you use OpenVINO, and read the full Keras 3.16.0 release notes.
