Changelog
Best viewed here.
All notable changes to PhiJAX are documented in this file.
The format follows Keep a Changelog, and PhiJAX follows Semantic Versioning.
Unreleased
0.2.0b6 - 2026-11-06
Added
ModelCheckpointacceptsmonitor="step"to rank checkpoints by training step. (#51)- The terminal checkpoint from
save_lastorsave_on_exceptionis replaced by the next one, including across resumed fits, instead of accumulating. (#51) TrainState.input_statisticsstores the model's input normalization statistics asInputStatistics, so checkpoints keep the normalization a model was trained with. (#53)load_input_statistics()reads the statistics stored in a checkpoint. Return it from a DataModule'sinput_statistics()to start transfer learning from the source statistics. (#53)BasePhiModule.input_statistics,input_periods, andbind_inputs()let the Trainer rebind a module to restored statistics and periods. (#57)PhiDataModule.input_periods()declares physical periods of periodic input axes, andTrainState.input_periodsstores them with checkpoints. Resume and prediction use the stored periods; transfer learning uses the target DataModule's;periodic_features_kwargs['periods']overrides both. (#57)ExactNTKBalancer(kernel_size=...)accepts"all"to compute the NTK on every row of a finite pool, and a mapping that sets the sample count per objective batch key, such as{"pde": 1024, "boundary": "all"}. (#63)ExactNTKBalancer(resample=True)draws new diagnostic batches for every update instead of once per fit. Custom balancers request the same behavior withBalancerUpdatePlan(resample=True). (#63)Trainer.should_stoplets callbacks request a clean stop, as in Lightning. ReturningTruefromon_train_batch_end()still works and sets the flag. (#64)EarlyStoppingacceptscheck_finiteandcheck_every_n_steps, and stores its progress in checkpoints, so a resumed fit stops at the same step as an uninterrupted one. Progress stored for a differentmonitorormodeis skipped with a warning, and a changedpatiencekeeps the configured value with a warning. (#64)Trainer.predict()runs across several JAX processes. Each process predicts an equal share of every prediction batch, and the outputs are gathered so every process returns the complete predictions in batch order. With several devices, prediction chunks no longer need to be divisible by the device count; they are padded instead. (#76)- The
allextra installs every optional feature:hydra,io,tensorboard, andwandb. Combine it with at most one accelerator extra, such asphijax[all,cuda13]. (#86) load_model_state()andOrbaxCheckpointIO.restore_model_state()restore only a checkpoint's model state, without an optimizer or balancer template.OrbaxCheckpointIO.restore_input_periods()reads the stored input periods. (#91)Trainer.predict(module, ckpt_path=...)predicts with a module blueprint, as Lightning'spredict(model, ckpt_path)does. The Trainer builds the model with the checkpoint's input statistics and periods and restores only the model state, so prediction needs no optimizer, balancer, seed, or fit-stage data. For schema-2 checkpoints, which store neither, it takes them from the DataModule's fit stage with a warning. Reading them directly raisesLegacyCheckpointError. (#92)PhiDataModule(batch_sizes=...)enables defaulttrain_batch_source()andpredict_batch_source()hooks, andprediction_pool()returns the pool namedpredict, chunked bybatch_sizes["predict"]. A DataModule that only builds pools overrides onlysetup(). (#96)ChunkedPredictionSource(pool, "all")predicts the whole pool in one chunk, split over the devices. (#96)- An equation with one loss may return its residual array directly, and a tuple entry may be an array instead of a
one-array group, so
return residualreplacesreturn ((residual[:, None],),). (#98) HostPool.from_grid(inputs, targets, mask=...)builds a pool from dense[*grid, features]arrays and records the grid, soreconstruct_predictions()returns[*grid, outputs]withNaNoutside the optional mask. (#97)
Breaking changes
-
ModelCheckpointnow owns checkpoint retention, following Lightning'sModelCheckpoint:OrbaxCheckpointIOno longer acceptsmax_to_keepand never deletes checkpoints on its own.save_top_kdefaults to1, soModelCheckpoint(checkpoint_io)keeps only the latest checkpoint instead of every checkpoint. Passsave_top_k=-1to keep every checkpoint.- Without
monitor,save_top_kmust be-1,0, or1. - To keep the latest
kcheckpoints, replacemax_to_keep=kwithModelCheckpoint(..., monitor="step", mode="max", save_top_k=k). See the migration guide. (#51)
-
Trainer(max_steps=...)is now the global optimizer step at which training stops, as in Lightning. A fit resumed from stepNrunsmax_steps - Nupdates instead ofmax_stepsmore, and logs and progress bars follow the global step. Resume withmax_steps = N + extrato trainextramore steps. See the migration guide. (#62) -
EarlyStoppingfollows Lightning's callback: it checks metrics inon_train_metrics(), so it sees module-logged and callback metrics, and stops oncewait_count >= patienceinstead of> patience.bestandbad_checksare renamedbest_scoreandwait_count, and a NaN or infinite metric stops training immediately by default. See the migration guide. (#64) -
Periodic features use physical periods of the physical coordinate, so input normalization no longer affects periodic axes.
PeriodicFeaturestakesperiods={axis: T}instead ofaxesandfrequencies, model factories receiveinput_periods, andbind_input_statistics()is nowbind_inputs(). See the migration guide. (#57) -
ChunkedPredictionSourcebatches carry their padding mask asvalid_predict_maskinstead ofmask, so a pool can keep its ownmaskfield. Code readingbatch["mask"]inpredict_step()must readbatch["valid_predict_mask"]. A prediction pool with an auxiliary array namedvalid_predict_maskraisesValueError; previously amaskfield was silently replaced by the padding mask. (#72) -
Training batch sizes, NTK diagnostic sizes, and prediction chunk sizes count rows per device, as in Lightning:
NamedBatchSourcebatch sizes,ExactNTKBalancerkernel_size, and theChunkedPredictionSourcechunk size. The Trainer scales built-in sources with their newfor_devices()method, so sizes no longer need to divide by the device count. Single-device runs are unchanged; to keep the same global batch onndevices, divide each size byn. See the migration guide. (#79, #81) -
Training and NTK batches drawn with
"all"are replicated on every device instead of split by rows, so a pool no longer needs to divide by the device count, and with several processes the pool counts once instead of once per process. The loss is unchanged.Strategy.place_batch()takes areplicatedargument naming the batches to replicate; the Trainer passes it only when a batch uses"all". (#79) -
hydra-core,omegaconf, androotutilsmove to thehydraextra, andh5py,mat73, andscipyto theioextra. Installphijax[hydra,io]forphijax.integrations, the Hydra entrypoint utilities, and MATLAB or HDF5 files. Without an extra, these features raiseModuleNotFoundErrornaming the extra to install. Training, NPZ files, and prediction artifacts need neither. See the migration guide. (#86) -
CheckpointIO.restore_weights()andOrbaxCheckpointIO.restore_weights()are removed. Usereplace(state, model_state=checkpoint_io.restore_model_state(state.model_state)), orload_model_state()outside a backend. CustomCheckpointIObackends implementrestore_model_state(),restore_input_statistics(), andrestore_input_periods()instead. (#91) -
Trainer.predict_state()is removed. Usepredict(fit_result, ...)in memory, orpredict(module, ckpt_path=...)from a checkpoint without building a state template. (#92) -
The Trainer has two public tasks,
fit()andpredict(), as in Lightning.Trainer.fit_state(),initialize_state(),compile_train_step(),load_weights(),latest_checkpoint(),TrainingPlan, andbuild_training_plan()are removed, andmake_train_step()andinitialize_train_state()are no longer exported fromphijax.training. A customBasePhiModuletrains withfit()by overriding the newconfigure_model()hook, which replacesPhiModule.prepare_model(). See the migration guide. (#93) -
ProgressBar,TQDMProgressBar, andRichProgressBarno longer taketotal. As in Lightning, a progress bar counts to its Trainer'smax_steps. Removetotal=...from constructors andtotal: ${trainer.max_steps}from Hydra callback configs. (#89) -
TrainerContext.callback_statesis removed.ModelCheckpointreads callback states from its connected Trainer when it saves, so the field was never needed. (#95) -
The Trainer owns the DataModule stage, as Lightning's data connector does.
PhiDataModule.prepare_stage(),teardown_stage(), andprepared_stageare removed; callsetup()andteardown()to inspect pools outside the Trainer. Becauseprediction_pool()now returns a pool namedpredict, the defaultnormalization_pools()excludes that pool. See the migration guide. (#96) -
build_array_pools(),create_sampler(), andSamplerNameare removed, andphijax.data.samplers.sample_pool()is private. Build pools with NumPy andHostPool.from_grid(), and construct samplers directly. See the migration guide. (#97) -
ResidualTerm(..., ntk_stream="output")raises at construction unless the equation declaresresidual_equation(..., default_ntk_stream="output"). Residual-only equations no longer need to reject the"output"stream themselves. (#98) -
Built-in equations return arrays instead of one-array groups, and are annotated as
ResidualOutput. A direct call returnsresidualfor one loss and a tuple of[samples, 1]arrays for each Navier--Stokes component, so indexresultorresult[i]instead ofresult[0][0]orresult[i][0].phase_wrapped_fidelitystill returns its((cosine, sine),)group. Objectives built withResidualTermare unaffected. (#99) -
phijax.metricsmoved tophijax.core.outputs, next to the module contract that returnsTrainingOutput. ImportTrainingOutputfromphijaxorphijax.trainingas before, or fromphijax.core. (#103)
Changed
- Checkpoints use schema version 3. Schema-2 checkpoints from 0.2.0b5 still restore, using the current DataModule's input statistics with a warning. PhiJAX 0.2.0b5 cannot read schema-3 checkpoints. (#53)
- The Trainer runs
ModelCheckpointafter all other callbacks, as in Lightning, so each checkpoint stores the state every other callback reached at that step. (#64) - The first
Ctrl+CorSIGTERMduring fitting now lets the current step finish before interrupting, so the returned state and thesave_on_exceptioncheckpoint always match a completed step. A repeated signal still stops immediately. (#67) - The Trainer calls
PhiDataModule.prepare_data()only on global process zero. Other processes wait at the newStrategy.barrier()and then runsetup(), so prepared files must be on storage every host can read. Single-process runs are unchanged. See multi-process runs. (#69) ModelCheckpointalways saves the last completed step when a fit stops onSIGTERM, as on preemption, even withoutsave_on_exception=True. (#75)phijax,phijax.data,phijax.evaluation, andphijax.utilsimport their public names on first use, soimport phijaxno longer loads JAX. NumPy-only modules, such asphijax.data.poolsandphijax.evaluation, load without JAX. (#85)Trainer.fit(..., ckpt_path="last")warns and starts from fresh state when no checkpoint has been saved yet, as in Lightning, instead of raisingFileNotFoundError. One Hydra config can then passckpt_path=lastfor both the first run and every resume. An explicit checkpoint path, andpredict(..., ckpt_path="last"), still raise. (#94)NamedBatchSourcedraws a step's batches in one compiled call instead of one dispatch per array operation. On a GPU, this makes the quickstart about 3.8 times faster; batches are unchanged bit for bit. CustomBatchSampler.sample()implementations must be traceable byjax.jit. (#100)Trainer.predict()compilespredict_step()once per call instead of running it eagerly for every chunk, which makes prediction several times faster on CPU and much faster on GPU. Custompredict_step()overrides must be traceable byjax.jit. (#102)- Updated JAX to 0.12.0.1, Flax to 0.12.12, and Orbax Checkpoint to 0.12.9. (#43, #78)
- Updated
hydra-coreto 1.3.8, now in thehydraextra. (#42) - Updated the optional W&B dependency to
>=0.31,<0.32. (#49)
Fixed
- Fixed a crash with
FileNotFoundErrorwhen monitored top-k retention and Orbaxmax_to_keepdeleted the same checkpoints. Ranking now always matches the stored checkpoints, and restored ranking state drops steps that are no longer stored. (#51) - Top-k displacement no longer deletes the checkpoint at
last_model_path. (#51) ModelCheckpointdeletes a displaced checkpoint only after the next checkpoint write has committed, so an interrupted asynchronous write never removes the only valid checkpoint. (#51)OrbaxCheckpointIO.deletenow ignores steps that are not stored. (#51)- A full resume and prediction from a checkpoint now use the input statistics the model was trained with. Previously
they were recomputed from the current DataModule, which silently changed the model if the data had changed.
Transfer learning with
weights_only=Truestill uses the current DataModule's statistics. (#53) - Resuming with a different set of callbacks no longer raises. Following Lightning, added callbacks start fresh, and stored state for a removed stateful callback is skipped with a warning. Toggling stateless callbacks, such as the progress bar or model summary, neither fails nor warns. (#54)
OrbaxCheckpointIOno longer makes Orbax logItem "default" ... could not be restoredon every checkpoint metadata read, such as each restore. (#55)spherical_navier_stokesnow preserves the sign ofsin(th)when clamping it, so polar angles outside[0, pi]give correct residuals. (#59)- Fidelity and boundary equations now raise
ValueErrorfor out-of-rangeoutput_indicesortarget_indicesinstead of producing NaN residuals. (#60) - A resumed fit now draws the same exact-NTK diagnostic batches as an uninterrupted run. Previously the batches depended on the step the fit resumed from. (#63)
- A failing
on_exception, logger finalization, or teardown hook no longer replaces the original training or prediction error, and no longer skips the remaining cleanup. The failure is logged and attached to the original error as a note. (#66) ExactNTKBalancerandGradNormBalancerkeep their previous weights when an update sees an infinite NTK trace or gradient norm. Previously one infinite value turned the weights intoinfornanfor the rest of training. (#68)save_prediction_artifact()andreconstruct_predictions()reject a pool whoseflat_indexrepeats an index. Previously the save kept only the last of the repeated rows and wrote an artifact thatload_prediction_artifact()rejects. Artifact files are now written to a temporary file and renamed into place, so an interrupted save keeps the previous file. (#71)load_arrays()returns classic (pre-v7.3) MATLAB structs as nested dictionaries, as it already did for v7.3 files, so nested keys such asget_array(arrays, "results/velocity")work. Previously such structs loaded as SciPymat_structobjects and nested keys raisedKeyError. (#73)HostPoolrejects auxiliary arrays namedinputsortargets, which previously replaced the pool's own arrays in sampled batches, and reports 0-d auxiliary arrays with a clearValueErrorinstead of anIndexError. Theuniform_domainsampler generatesfloat32coordinates fromfloat64pool inputs without JAX truncation warnings unless 64-bit mode is enabled. (#74)- Multi-process
DataParallelStrategyfits now run. Previously they failed before the first step because state and PRNG keys were placed withjax.device_puton devices of other processes. Each process now samples different rows through the newStrategy.process_key(),devicescounts or indexes each process's local devices, and fitting raisesValueErrorwhen the starting state differs between processes. A stop requested by any process stops every process after the same step:trainer.should_stopandSIGINTare combined with the newStrategy.reduce_boolean_decisions(), andSIGTERMuses JAX's preemption sync step. A two-process CPU integration test covers fitting, resuming, and each stop request. (#75) ExactNTKBalanceraverages each term's NTK over all rows of the batches that term reads. With akernel_sizemapping of different sizes, every term was mapped over all diagnostic batches together: the defaultkernel_chunk_size=1silently kept only as many rows as the alphabetically first batch, and other settings raised an error.BasePhiModule.stream_batch_keys()andCompositeObjective.stream_batch_keys()report the batches of each stream; a stream reading batches of different sizes raisesValueError. (#80)ExactNTKBalancerevaluates each device's own diagnostic rows in parallel. Before, the defaultkernel_chunk_size=1made XLA gather every diagnostic row onto every device, so each device computed the whole diagnostic batch. (#81)pre_hydra_routine()takes asearch_frompath, and entrypoints should pass their own__file__. It used to search for the project root from PhiJAX's installed source file. That found the right root only when PhiJAX was installed in a virtual environment inside the project. An editable PhiJAX checkout exported its own root, and an environment outside the project raisedFileNotFoundError. The default search now starts in the working directory. (#87)Trainer.fit(..., weights_only=True)reads only the model state. Before, it restored the whole state first, so it raisedValueErrorwhenever the optimizer or balancer differed from the checkpoint's, for example after switching from Adam to SGD. (#91)Trainer(precision="64-true")enables JAX x64 itself. Before, it raisedValueErrorunless the caller had runconfigure_precision()first, so a Hydra config withprecision: 64-truecould not train. (#89)fit()andpredict()run with the strategy's root device as the JAX default device, so arrays JAX creates implicitly during a task land on the Trainer's device. Previouslyaccelerator="cpu"on a GPU machine split placement across two devices and copied data every step. (#101)
0.2.0b5 - 2026-09-11
Added
- Added
no_slip_boundarywith configurable velocity components and residual/output streams for stationary and moving walls. (#39) - Added configurable weight, projection, and period batch keys to fidelity equations, and a configurable normals key to
free_slip_boundary. (#38)
Breaking changes
phase_wrapped_fidelitynow usesbatch["projection"]when present. Setprojection_key=Noneto preserve direct supervision when that field contains unrelated data. (#38)
Changed
- Updated the optional W&B dependency to
>=0.30,<0.31. (#37) - Added an optimizer guide covering Optax, the optional SOAP_JAX compatibility fork, and checkpoint restoration. (#40)
- Clarified installation workflows with uv and pip. (#36)
Fixed
- Log all term losses before loss-balancer weights for consistent metric ordering. (#35)
0.2.0b4 - 2026-09-03
Added
- Added public type aliases for supported accelerator, device, precision, monitoring, activation, and initialization options. (#25)
Breaking changes
- Removed the inert
Trainer.deterministicoption. Deterministic GPU experiments must configure XLA before JAX initializes. (#30)
Changed
- Reorganized the documentation into task-oriented guides and focused API reference pages. (#26, #27, #28)
0.2.0b3 - 2026-09-01
Added
- Added a
target.nameOmegaConf resolver for deriving display labels from Hydra_target_paths. (#22)
Breaking changes
- Made
LearningRateMonitorrequire an explicit optimizer name and changed its default metric group fromtrain/tooptimizer/, using Lightning-style keys such asoptimizer/lr-Adam. (#22)
Changed
- Made the Trainer report its precision and accelerator environment automatically when constructed on global rank zero. (#21)
- Expanded the balancer documentation with the exact metrics, meanings, update behavior, and default destinations for static, gradient-norm, and exact-NTK balancing. (#23)
0.2.0b2 - 2026-09-01
Added
- Added
to_hyperparameters()for converting composed Hydra configs before passing them toTrainer.fit(). (#19)
Breaking changes
- Removed callback and logger
enabledconfiguration options. Omit a service entry to disable it. (#16) - Removed
Trainer.set_logger(). Construct loggers first and pass them throughTrainer(logger=...)orinstantiate_trainer(..., logger=...);instantiate_loggers()no longer accepts a Trainer. (#19) - Renamed the experiment logger method
log_hyperparameters()to the Lightning-stylelog_hyperparams(). (#19)
Changed
- Made CSV, TensorBoard, and W&B logger resource setup lazy, idempotent, and restricted to global rank zero during Trainer tasks. Direct built-in logger use still starts resources automatically on first use. (#19)
0.2.0b1 - 2026-08-31
Added
- Concise
Trainer.fit()andTrainer.predict()APIs that initialize models, state, balancing, batch routing, and compiled plans from a module blueprint, DataModule, optimizer, and seed. (#15) ModelFactory, balancer-owned adaptive update plans, objective equation composition, finite-pool batch-source construction, and safeHostPooldefaults. (#15)- Independent persistent PRNG streams for model execution, sampling, and adaptive-balancer diagnostics. (#15)
- Structured training diagnostics with host-side
PhiModule.log()control for loggers and progress displays. (#15) - Automatic TQDM progress, plain model summaries, default TensorBoard or CSV logging, and versioned run directories. (#15)
- Monitored top-k checkpoints with persistent callback state and experimental TPU installation support. (#15)
Breaking changes
- Renamed the explicit execution APIs to
Trainer.fit_state()andTrainer.predict_state(). (#15) - Changed
PhiModuleinto an immutable model-factory blueprint; the bound module is returned asFitResult.module. (#15) - Changed
ResidualTermto accept its residual function first and infer its default NTK stream from equation metadata. (#15) - Raised the checkpoint schema to version 2 for the expanded
TrainStatelayout. (#15) - Moved adaptive cadence and diagnostic sampling settings into adaptive-balancer constructors. (#15)
- Replaced the adaptive
skip_first_stepflag with cadence-anchoredupdate_start_stepscheduling. (#15) - Removed separate sampling and balancer key arguments from Trainer methods; both now live in
TrainState. (#15) - Removed
resume_latest()in favor offit(..., ckpt_path="last"). (#15) - Removed the low-level
with_balancer_updates()helper; advanced schedules now belong toTrainingPlan. (#15) - Removed
BalancerUpdateConfigandBalancerUpdateSchedule;TrainingPlannow accepts oneBalancerUpdatePlan. (#15) - Removed the Hydra
balancer.factoryandbalancer.updatelayers; balancer groups are directly instantiable. (#15) - Removed
MetricRoute; modules now customize metric destinations withself.log()fromon_train_batch_end(). (#15) - Removed the
phijax.moduledeep import path; use top-level imports orphijax.corefor custom module contracts. (#15)
Changed
- Made DataModule input normalization opt-in through
input_statistics(). (#15) - Made
LearningRateMonitorrequire a configured experiment logger before fitting begins. (#15) - Moved adaptive-balancer scheduling into the Trainer host loop and removed unconditional per-step transfers of
TrainState.step. (#15) - Split module contracts into
phijax.coreand moved fit, prediction, logging, and signal orchestration into private loops and connectors while keeping the top-level API unchanged. (#15)
0.1.0b1 - 2026-08-28
Added
- Initial beta API for building, fitting, and evaluating physics-informed neural networks with JAX. (#1)
- Lightning-inspired
Trainer,PhiModule,DataModule, callback, logger, and checkpoint lifecycles. (#1) - Explicit model, optimizer, loss-balancer, PRNG, and training state for compiled updates. (#1)
- Selective coordinate derivatives and reusable PDE, boundary, data-fidelity, and objective components. (#1)
- Static, normalized-static, gradient-norm, and exact-NTK loss balancing. (#1)
- MLP, Modified MLP, and PirateNet architectures with a common model initialization contract. (#1)
- CPU, CUDA 12, and CUDA 13 installation options, configurable precision, and centralized device placement. (#1)
- Versioned checkpoints and portable prediction artifacts for downstream evaluation. (#1)
- Optional Hydra integration and Weights & Biases and TensorBoard logging. (#1)