Repository navigation
Keras 3.16.0 Release Notes
638PULL REQUESTS |
108CONTRIBUTORS |
81FIRST-TIME CONTRIBUTORS |
9NEW OPS |
40+BACKEND-AGNOSTIC OPS |
2NEW LAYERS |
| 🔌 Pluggable Backends backends as separate packages |
🔢 x64 Mode opt-in 64-bit dtypes |
🚀 XLA SavedModel Export JAX to XLA Serving Engine |
⚡ Faster Training Loops steps_per_execution on JAX & PyTorch |
🪶 Quantization ternary · 2-bit packing · GPTQ / AWQ |
🧮 New Ops grad · cov · matrix_power · lgamma |
| 🧵 PyTorch Distribution data parallel · model parallel |
🔥 torch.compile Friendly fewer graph breaks |
🧪 TensorFlow-free Groundwork JAX CI without TensorFlow |
🖼️ New Layers & Losses TernaryDense · Mosaic · sparse focal |
☁️ Remote Paths gs:// without TensorFlow |
🛡️ Security Hardening safer loading and deserialization |
Highlights
🔌 Pluggable Backends
Keras backends no longer have to live inside the keras package. A backend can now ship as its own keras_<name> package and is loaded when KERAS_BACKEND names it, while jax, numpy, tensorflow and torch stay built in. (#23795, #23770, #23642, #24447)
- OpenVINO is now a pluggable backend. It has moved out of this repository into keras-team/keras-openvino. (#23858)
- MLX is a recognized pluggable backend through the
keras-mlxpackage. (#23795, #24444) - Install extras:
pip install "keras[openvino]"andpip install "keras[mlx]"pull in the matching3.16.*backend package. (#24444) - Bring your own backend: set
KERAS_ALLOW_UNOFFICIAL_BACKEND=1to load anykeras_<name>package as a backend, for developing and testing new ones against a standard Keras install. (#24232)
# pip install "keras[openvino]"
import os
os.environ["KERAS_BACKEND"] = "openvino"
import keras🔢 64-bit dtype control with x64_mode
A new setting decides whether 64-bit inputs keep 64-bit results. Set it with keras.config.set_x64_mode(), the KERAS_X64_MODE environment variable, or the "x64_mode" field of keras.json. (#24047, #24265, #24270, #24302, #24307, #24308, #24147)
"off"is the default on JAX, NumPy and PyTorch: results are capped to 32-bit."explicit_x64"is 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 requires JAX 0.8.0 or newer."enable_x64"is reserved and not supported yet.
keras.config.set_x64_mode("explicit_x64")
x = keras.ops.ones((2,), "int64")
keras.ops.add(x, x).dtype # int64🚀 XLA SavedModel export
model.export(path, format="xla_saved_model") exports a model on the JAX backend to the XLA Serving Engine format. It requires the xla-saved-model package. (#24143, #24097)
⚡ Faster multi-step training loops
- On JAX,
steps_per_execution > 1withjit_compile=Truenow runs the steps on-device withjax.lax.scan, with one host dispatch per group of steps. (#23527) - The PyTorch backend now supports
steps_per_execution > 1. (#23234) steps_per_executionhandling was optimized across backends. (#23305)
🪶 Quantization
keras.layers.TernaryDense: a dense layer trained with weights constrained to{-1, 0, +1}, which can be frozen to packed ternary weights withlayer.quantize("ternary"). (#22960, #23758, #23906, #23909)- New public helpers:
keras.quantizers.TernaryQuantizationConfig,QuantizationReport, and thepack_int2/unpack_int2/pack_ternary/unpack_ternarycodecs. (#22960, #23345, #23470) model.quantize()is observable and fail-safe. (#23345)- GPTQ and AWQ reworked: batched calibration with a Cholesky inverse-Hessian, AWQ aligned with the reference implementation, one-step quantization without a pending state, and calibration of third-party layers that declare support. (#23481, #23478, #24174, #24221, #24237, #24015, #24057)
- One quantization protocol across layers:
Dense,EinsumDense,Embedding,ReversibleEmbeddingandTernaryDensenow share a geometry protocol and a strategy registry. (#23521, #23591, #23606, #23630, #23758)
New Features
Ops
keras.ops.grad(experimental): returns a function computing the gradient off, on backends with automatic differentiation. (#23670)keras.ops.cov,keras.ops.matrix_power,keras.ops.column_stack,keras.ops.copysign,keras.ops.float_power,keras.ops.lgammaandkeras.ops.gammainc. (#23494, #23227, #23153, #23498, #23500, #23541, #23549, #23365)keras.ops.image.reconstruct_patches: the inverse ofextract_patches, withchannels_firstsupport, inferredoutput_sizeforpadding="valid", and overlapping patches. (#22984, #23267, #23319, #23930)keras.ops.top_kacceptsis_stable. (#23367)keras.ops.linalg.normaccepts a list foraxis. (#23721)keras.ops.in_top_ksupports multi-dimensional inputs. (#23232)keras.ops.crosssupports 2-D vectors on PyTorch and JAX. (#23801, #23769)keras.ops.image.resizesupports Lanczos interpolation on PyTorch. (#23792)- TensorFlow convolutions support
strides > 1together withdilation_rate > 1. (#23181)
Layers and losses
keras.layers.Mosaic: a mosaic image augmentation layer. (#23963)keras.losses.SparseCategoricalFocalCrossentropyandkeras.losses.sparse_categorical_focal_crossentropy. (#23482)label_smoothinginSparseCategoricalCrossentropy. (#23488)Layer.add_weightaccepts alayoutargument. (#24058)adapt()shows a progress bar, and inDiscretization,IndexLookupandTextVectorizationit now takes the inputs from(x, y)batches, such as those yielded by aPyDataset. (#22971, #23362, #23440)keras.layers.GroupedQueryAttentionis now the canonical name, withGroupQueryAttentionkept as an alias. (#23905)
Saving and data
keras.saving.load_modelaccepts file objects (io.IOBase). (#23873)ModelCheckpointsupports remote paths. (#24092)- Remote paths such as
gs://work without TensorFlow through the newgcsextra:pip install "keras[gcs]". (#24020, #24098, #24081) audio_dataset_from_directorysupports Grain. (#23224)
Distribution on PyTorch
- Data parallel and model parallel training on the PyTorch backend, with
DTensorsupport for Keras variables and distribution utilities. (#23316, #23402, #23404, #23366, #23052, #23403) - Multi-process sharding for Torch
DataLoader,PyDatasetand NumPy adapters. (#23045, #23044, #23046) jit_compile=Trueworks under torchDataParallel. (#23948)
Backend-agnostic Ops and TensorFlow-free Groundwork
- More than 40 ops gained a backend-agnostic implementation, including the
nan*reductions, the split and stack family, window functions,correlate,corrcoef,histogramandargpartition. The TensorFlow backend now uses several of them directly. (#23643, #23854, #23925, #24041, #24131, #24344, #24367, #24443) - A CI job runs the JAX tests with TensorFlow uninstalled, to catch new TensorFlow dependencies outside the TensorFlow backend. (#24145)
- The TensorBoard callback works without TensorFlow: when TensorFlow is not installed, it writes scalars, the model summary, histograms and images with
tensorboardX. (#24198, #24238) - A new
OpTestharness checks each op across input dtypes, 64-bit dtypes,floatxsettings, the backend JIT, functional models and gradients. (#23970, #24187, #24212, #24230, #24240, #24266, #24277)
Performance
- PyTorch: removed
torch.compilegraph breaks in model compilation,dot_product_attention,BatchNormalization,UnitNormalization,SGDandAdadelta;channels_lastpooling; a direct path for pointwise convolutions; vectorized scatter for a much fasterMeanIoU; a GPU memory leak fixed in tree utilities. (#23744, #23327, #24083, #24159, #23949, #23645, #23178, #23196, #23111) - Layer call overhead: faster input compatibility checks, a single name scope per call, cheaper dtype standardization, and traceback argument info built only on error. (#23184, #23301, #23200, #23183, #23182)
- Data: no tensor copies when using a
tf.data.Datasetwith JAX or NumPy. (#24291) - Normalization: backends can provide fused RMS and layer normalization. (#23510)
Security
- Restricted unpickling when loading the IMDB, Reuters and CIFAR datasets, and pinned SHA-256 hashes for Fashion-MNIST. (#23047, #23252, #24036)
- Rejected decompression bombs in
.kerasasset extraction, the remaining zip readers andKerasFileEditor. (#23101, #23212, #23303) - Verified all intermediary H5 groups when navigating H5 files, and validated the file name derived from
origininget_file. (#23168, #23330) - Rejected classes when deserializing a function config, and excluded visualization utilities from modeling API deserialization. (#24369, #24023)
- Removed unsupported NPZ weight storage and consolidated ZIP validation. (#23655)
Breaking and Behavior Changes
- OpenVINO is no longer bundled. Install it with
pip install "keras[openvino]". (#23858, #24444) - Minimum PyTorch version is now 2.6.0. (#24048)
- 64-bit inputs are now treated as 32-bit by default on JAX, NumPy and PyTorch (
x64_mode="off"), for example anint64tensor passed to an op givesint32. Setx64_mode="explicit_x64"to keep them. If you set JAX's own 64-bit flags yourself and they do not matchx64_mode, Keras warns. (#24308, #24047) .kerasarchives with NPZ weights no longer load. The unsupportedmodel.weights.npzstorage was removed. (#23655)keras.ops.sizereturns a Pythoninton every backend. (#23496)keras.ops.layer_normalizationno longer accepts arbitrary keyword arguments. (#24278)- Integer inputs are promoted to float in activations and math ops such as
leaky_relu,hard_sigmoid,hard_silu,selu,softsign,sigmoid,softmax,erf,erfinvandrsqrt. (#23608, #23545, #23639, #23853, #24163, #24321, #24322) - RNN layers no longer propagate masks automatically, which fixes a CTC loss dimension mismatch. (#23235)
- TensorFlow:
jit_compile=Trueunder a multi-replicatf.distributestrategy now warns and falls back tojit_compile=False, andkeras.ops.meanno longer upcastsfloat16andbfloat16tofloat32. (#24301, #23802) - Stricter argument validation now raises on invalid values for
RMSpropandAdadeltarho,Adagradinitial_accumulator_value,BatchNormalizationmomentum,GroupNormalizationepsilon,Huberdelta, losslabel_smoothingandEarlyStoppingpatience. (#23676, #23677, #23624, #23623, #23675, #23573, #23504, #23559)
Bug Fixes and Improvements
- Losses and metrics: fixed the alpha and beta swap in Tversky loss,
R2Scoreon zero-variance data and its sample count,IoU.resultwith a non-last axis,FBetaScoresample weights, and losses droppingdeltaoraxison serialization. (#23333, #23420, #23334, #23668, #23335, #23286) - Layers: fixed
RandomCropbounding box offsets,Bidirectionaloutput shape with an asymmetric backward layer, attention weights for fully masked rows,betain layer and group normalization for large inputs, and Functional models accepting inputs with a mismatched last axis or dict inputs with extra keys. (#23519, #23687, #23902, #23782, #23924, #23920, #23261) - Saving: fixed
Sequential.from_configvariable paths so Orbax checkpoints restore weights, function serialization on Windows,Layerpath reconstruction on reload, and compile config mutation during HDF5 save. (#24055, #23631, #24087, #23475, #23870) - PyTorch: fixed
lstsqon GPU,linspaceandlogspaceend points andnum=1, symmetric padding,crossdefault axis, stateful GRU and LSTM cuDNN backward, float64 on MPS, and ONNX export with dynamic shapes. (#24146, #24305, #24236, #23230, #23219, #23464, #23701, #23058) - TensorFlow: fixed
rot90for non-square arrays,unravel_indexorder,searchsortedfor multi-dimensional values,trilandtriuwith out-of-rangek,map_coordinatesmirror and reflect modes, and exactfloor_dividefor floats. (#23435, #23434, #23436, #24070, #24014, #23938, #24056) - JAX: fixed window ops under
jax.jit,StopIterationduring validation on empty datasets, and 64-bit NumPy data infit,evaluateandpredict. (#24337, #23690, #24147) - NumPy 2.x and Python 3.14 compatibility fixes. (#24242, #24275, #23408, #23259)
CI & Infrastructure
- Releases publish to PyPI through OIDC trusted publishing. (#23557)
- GPU and TPU tests are split into four shards and triggered by a one-shot
run-gpu-tpu-testslabel. (#24144, #23857) masternow carries a.dev0version between releases. (#24347)- The import test flow runs against the installed wheel. (#24458)
- CPU tests moved to a reusable workflow on
linux-x86-n4-16runners, and auto-assignment, stale and Zizmor checks moved to shared workflows. (#23572, #24062, #23471, #24178, #24179)
Contributors
We would like to thank all contributors for this release: @2sumtech, @AbdulAliMamnun, @ahlag, @andersendsa, @andife, @Andreas-Hum, @anishmehta24, @aswanth-07, @Ayoubhm07, @Bratet, @brianmanderson, @buildwithsuhana, @bzantium, @calad0i, @ChiragSW, @CodingSelim, @DavidAriOstenfeldt, @davidtungy, @Deeven-Seru, @devs6186, @DisturbedCrow, @divyashreepathihalli, @FactualExplorer, @fchollet, @fhchl, @gaga1313, @GargiGupta-io, @gaurav-gandhi-2411, @GodlyDonuts, @goyaladitya05, @hertschuh, @iezepov, @ILCSFNO, @indrajeetapache, @IshaanPotle, @ishitta-iyer, @james77777778, @jayzuccarelli, @jdymitarai, @jeffcarp, @jerryxyj, @jjdev11, @JyotinderSingh, @Kaif10, @KaiOnCode, @kaivalya-cyber, @karpovantonme, @laxmareddyp, @lequangdung2005, @LinZiyuu, @MaddipatlaChetan24, @madhanalagarsamy, @maitry63, @marco-trotta1, @MarcosAsh, @mayankdas2005, @mncrftfrcnm, @mohammadmseet-hue, @mr-field, @mrinalghoshh, @MrNagabhushana-0-dev, @Nanduu24, @Neilblaze, @Nicholas022400701, @Noxtimo, @nurulgofran, @Osamaali313, @pandeylakshya207-max, @patminn107, @pctablet505, @peinguim, @Phoebus-Liu, @princemittalr, @priyankn, @Priyanshu-byte-coder, @pwuertz, @rootkiller6788, @rstar327, @SABITHSAHEB, @SamanehSaadat, @samudraneel05, @sandeepvijayarao09, @SEPURI-SAI-KRISHNA, @SharadhNaidu, @shashaka, @Shi-pra-19, @Sid-5137, @SID-6921, @simeon-kepp, @Snakinya, @sohumt123, @sugata100, @tandede, @TheManishCode, @UgaTheDev, @ujwalreddybattu04, @usmanmateen, @utsab345, @Vansh-Sharmaa, @vera-rubin, @VimalN2005, @Viranshul-P, @vishwakt, @vnayakde, @vruotolo, @winklemad, @yeti107, @zuccamia.
New Contributors
81 people made their first contribution in this release
- @pwuertz made their first contribution in #23095
- @devs6186 made their first contribution in #23177
- @CodingSelim made their first contribution in #23230
- @DavidAriOstenfeldt made their first contribution in #23111
- @Osamaali313 made their first contribution in #23202
- @brianmanderson made their first contribution in #22984
- @SABITHSAHEB made their first contribution in #23252
- @mohammadmseet-hue made their first contribution in #23254
- @SharadhNaidu made their first contribution in #23093
- @winklemad made their first contribution in #23265
- @mr-field made their first contribution in #23284
- @TheManishCode made their first contribution in #23242
- @sohumt123 made their first contribution in #23286
- @patminn107 made their first contribution in #23171
- @MrNagabhushana-0-dev made their first contribution in #23221
- @simeon-kepp made their first contribution in #22960
- @mncrftfrcnm made their first contribution in #23328
- @madhanalagarsamy made their first contribution in #23368
- @Priyanshu-byte-coder made their first contribution in #23329
- @mrinalghoshh made their first contribution in #23391
- @Kaif10 made their first contribution in #23375
- @indrajeetapache made their first contribution in #23464
- @Vansh-Sharmaa made their first contribution in #23411
- @SEPURI-SAI-KRISHNA made their first contribution in #23423
- @pandeylakshya207-max made their first contribution in #23447
- @karpovantonme made their first contribution in #23477
- @2sumtech made their first contribution in #23542
- @sugata100 made their first contribution in #23376
- @IshaanPotle made their first contribution in #23505
- @lequangdung2005 made their first contribution in #23465
- @aswanth-07 made their first contribution in #23428
- @Sid-5137 made their first contribution in #23535
- @marco-trotta1 made their first contribution in #23550
- @KaiOnCode made their first contribution in #23558
- @tandede made their first contribution in #23475
- @kaivalya-cyber made their first contribution in #23560
- @Neilblaze made their first contribution in #23500
- @UgaTheDev made their first contribution in #23417
- @GargiGupta-io made their first contribution in #23261
- @AbdulAliMamnun made their first contribution in #23571
- @gaurav-gandhi-2411 made their first contribution in #23420
- @Nicholas022400701 made their first contribution in #23668
- @Deeven-Seru made their first contribution in #23552
- @ishitta-iyer made their first contribution in #23482
- @Noxtimo made their first contribution in #23619
- @Bratet made their first contribution in #23716
- @yeti107 made their first contribution in #23720
- @MaddipatlaChetan24 made their first contribution in #23681
- @jjdev11 made their first contribution in #23788
- @jayzuccarelli made their first contribution in #23801
- @vruotolo made their first contribution in #23808
- @SID-6921 made their first contribution in #23860
- @iezepov made their first contribution in #23873
- @vishwakt made their first contribution in #23687
- @Phoebus-Liu made their first contribution in #23695
- @ujwalreddybattu04 made their first contribution in #23631
- @Nanduu24 made their first contribution in #23639
- @VimalN2005 made their first contribution in #23745
- @fhchl made their first contribution in #23651
- @Snakinya made their first contribution in #23212
- @ahlag made their first contribution in #23866
- @vera-rubin made their first contribution in #23932
- @rootkiller6788 made their first contribution in #23885
- @GodlyDonuts made their first contribution in #23723
- @usmanmateen made their first contribution in #23938
- @priyankn made their first contribution in #24023
- @jdymitarai made their first contribution in #23616
- @mayankdas2005 made their first contribution in #23963
- @princemittalr made their first contribution in #24055
- @davidtungy made their first contribution in #24141
- @Ayoubhm07 made their first contribution in #23880
- @vnayakde made their first contribution in #24088
- @zuccamia made their first contribution in #24175
- @Andreas-Hum made their first contribution in #24128
- @Viranshul-P made their first contribution in #24113
- @nurulgofran made their first contribution in #24065
- @anishmehta24 made their first contribution in #24105
- @DisturbedCrow made their first contribution in #24073
- @andife made their first contribution in #24214
- @FactualExplorer made their first contribution in #24256
- @sandeepvijayarao09 made their first contribution in #24159
Full Changelog: v3.15.0...v3.16.0