DAE-HardNet
Learn differential-algebraic systems with differentiable hard constraint projections.
Define coordinates, states, derivatives and algebraic constraints, then pass the processed problem to OHAGI's shared learning engine and PURIN's projection solvers.
- Differential processing: declared derivative specifications, discretization strategies and reconstruction of physical states and derivatives.
- Hard algebraic constraints: projected predictions under the selected solver's numerical tolerances.
- Flexible backbones: functional JAX networks and optional Flax adapters, with optional Orbax training checkpoints through OHAGI.
- Reusable deployment: a shared JAX bundle and the
DAEHardNet().load(...)facade.
Installation · Basic API · Load and predict · Documentation · Contributing · Citation
Installation
Requires Python 3.10 or newer. Install from PyPI:
python -m pip install daehn
For editable installs and optional Flax/Orbax integrations, see installation options.
Basic API
Learn a simple differential equation
Learn the decay law dy/dt + y = 0 from observations of y and dy/dt.
The example is self-contained: create data, define the equation, prepare the
projection, train and predict.
import jax
import numpy as np
from daehn import MLPBackbone
from daehn.dae import (
Coordinate, DifferentialState, DerivativeSpec, EquationBlock, DAESystem,
TaylorNeighborhood, compile_dae, DAETrainer, DAETrainingConfig,
)
jax.config.update("jax_enable_x64", True)
# 1. Data: time, observed state, observed derivative, physical parameters.
t = np.linspace(0, 1, 8)[:, None]
y = np.exp(-t)
dy = -y
p = np.empty((len(t), 0)) # This equation has no physical parameters.
# 2. Problem: declare y(t), dy/dt, and the residual dy/dt + y.
state = DifferentialState("y")
system = DAESystem(
coordinates=(Coordinate("t"),),
differential_states=(state,),
derivatives=(DerivativeSpec(state, (1,)),),
differential_equations=EquationBlock(lambda t, y, dy, p: dy + y, size=1),
)
# 3. Projection: process the differential equation using a Taylor neighborhood.
compiled = compile_dae(system, discretization=TaylorNeighborhood(deltas=(0.01,)))
projection = compiled.prepare_projection(batch_size=2)
# 4. Network and training: use the first four samples for training.
trainer = DAETrainer(
compiled=compiled,
prepared_projection=projection,
backbone=MLPBackbone(hidden_sizes=(8,)),
config=DAETrainingConfig(
epochs=2, pretrain_epochs=1, batch_size=2, hidden_sizes=(8,), print_every=0,
),
)
result = trainer.fit(
train_coordinates=t[:4], train_parameters=p[:4],
train_targets=y[:4], train_derivative_targets=dy[:4],
validation_coordinates=t[4:], validation_parameters=p[4:],
validation_targets=y[4:], validation_derivative_targets=dy[4:],
)
# 5. Predict the physical state y at a new time.
_, prediction, *_ = trainer.predict(result.parameters, [[0.7]], np.empty((1, 0)))
print(prediction)
DerivativeSpec(state, (1,)) declares the first time derivative. EquationBlock
returns residuals that should equal zero. DAETrainingConfig controls training
and loss weights; the tiny two-epoch budget above is only a runnable quick start.
Use DAETrainer to train differential models and DAEHardNet to load exported
inference models. See problem definitions for algebraic
constraints, initial conditions, discretization and custom backbones.
Load and predict
Load a previously exported physical-state deployment bundle:
from daehn import DAEHardNet
model = DAEHardNet().load("deployment/metadata.json")
prediction = model.predict([0.7])
For differential models, export the desired physical-state output graph explicitly; the inference guide shows how to export the example above.
The same deployment bundle also works through OHAGI:
from ohagi.inference import load
predictor = load("deployment/metadata.json")
for value in [0.4, 0.7, 1.0]:
prediction = predictor.predict([value])
Keep the referenced .jax_export file with metadata.json. Load once and reuse
the predictor. predict returns synchronized NumPy values; predict_jax keeps
outputs on the JAX device. Deployment uses the shared JAX pathway.
Data convention
Coordinates, physical parameters, states and derivatives are separate arrays,
with samples on the first axis and columns in declared/compiled order. Use
(n_samples, 0) when no physical parameters are present.
The HardNet stack
- KKTHN, DAEHN and NLPOPTNet supply problem formulations and framework-specific processing.
- OHAGI composes models, runs the shared learning engine, and handles checkpoints and JAX deployment.
- PURIN owns projection problems, numerical solvers, sparse kernels and projection differentiation.
Compatibility and validation
The PyPI CPU installation matrix covers Python 3.10–3.15 on Linux, Windows and macOS, plus Linux ARM64 on Python 3.13. It uses current compatible JAX releases; regular CI additionally tests JAX 0.6.2 on Python 3.12. See the release workflow for exact environments; accelerator installation follows the JAX guide.
- CI: tests, distribution builds and installation checks.
- Validation: public APIs, numerical references, documentation and code quality.
- Coverage: at least 90% combined statement and branch coverage; the badge links to the measured report for this branch.
- Security: CodeQL analysis and dependency review.
The frontend validation policy also checks API compatibility, checkpoint resume, types, dependency boundaries and cognitive complexity. See validation details.
Documentation
Read the full documentation — installation, tutorials, user guide and API reference.
The full Sphinx guide follows the Read the Docs style: contents, runnable examples, API reference and build instructions.
| Guide | Contents |
|---|---|
| Installation | Source installs, optional integrations and packaging |
| Problem definitions | Modeling, backbones and training |
| Inference | Export, loading and repeated prediction |
| Version notes | Current development behavior |
| Changelog | Recorded changes |
Contributing
Bug reports, examples and focused pull requests are welcome. Read CONTRIBUTING.md for setup, numerical checks and compatibility requirements. Keep generated results, environments and checkpoints out of Git.
Citation
Use CITATION.bib for a copyable BibTeX entry or GitHub's Cite this repository menu for citation metadata.
License
Apache License 2.0. Authorship and upstream attribution are recorded in AUTHORS and NOTICE.
Metadata
Release files for daehn 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| daehn-2.0.0.tar.gz | 195.1 kB | With provenance | Details for daehn-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| daehn-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for daehn-2.0.0-py3-none-any.whl |
Total release size: 240.7 kB
Release files / daehn-2.0.0.tar.gz
| Download URL | daehn-2.0.0.tar.gz |
|---|---|
| Size | 195.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4142b34de6e9f3315d9d5ea513c707a47b28e9b97d95bf966eeed1c4832b2715
|
|
BLAKE2b-256 checksum How to use checksums |
07988f18f3664b072a7c9a3fd9dd03b05893038c163da363e70c469da9511d72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / daehn-2.0.0-py3-none-any.whl
| Download URL | daehn-2.0.0-py3-none-any.whl |
|---|---|
| Size | 45.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26b43846e667961c0b83842688f7c0c79013c6b27f1cd8b9d062dbe4732d4aa3
|
|
BLAKE2b-256 checksum How to use checksums |
1308ae6e3ffd891e828193e1fed263e7a7a86ff3201aa70dfed6e6db343f4ff3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for daehn 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for daehn-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.