Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
512c56c
add jax serialisation
FFroehlich Nov 28, 2024
9fd5835
doc
FFroehlich Nov 28, 2024
862586d
no compilation for jax
FFroehlich Nov 28, 2024
674c481
bad ruff
FFroehlich Nov 28, 2024
3e7d453
Update ExampleJaxPEtab.ipynb
FFroehlich Nov 28, 2024
b2a95b1
bad ruff
FFroehlich Nov 28, 2024
8b713e6
Update ExampleJaxPEtab.ipynb
FFroehlich Nov 28, 2024
f79a96e
add nan safe log&divide
FFroehlich Nov 30, 2024
aec0712
merge
FFroehlich Dec 1, 2024
2672be2
some net cases and first ude testcase passing
FFroehlich Dec 2, 2024
76d599c
some more passing ude test
FFroehlich Dec 2, 2024
0605b78
updates
FFroehlich Dec 2, 2024
d166f03
Merge branch 'develop' into jax_sciml
FFroehlich Dec 2, 2024
ca209ac
fix merge
FFroehlich Dec 2, 2024
b201f4e
remove changes doc
FFroehlich Dec 2, 2024
ea1c75e
update net_004_alt test
FFroehlich Dec 2, 2024
b9add9d
refactor to pytests
FFroehlich Dec 3, 2024
484e853
Merge branch 'develop' into jax_sciml
FFroehlich Dec 3, 2024
eea558b
Merge branch 'develop' into jax_sciml
FFroehlich Dec 3, 2024
b8632f1
fixup merge
FFroehlich Dec 3, 2024
031b524
fix net test-cases
FFroehlich Dec 3, 2024
cfb0b5a
fixes & remove sciml dependency
FFroehlich Dec 3, 2024
2b698fb
Merge branch 'develop' into jax_sciml
FFroehlich Dec 6, 2024
d14d2af
Merge branch 'develop' into jax_sciml
FFroehlich Dec 8, 2024
8b8f9a8
fixup, add initial condition support
FFroehlich Dec 8, 2024
982d275
Update petab.py
FFroehlich Dec 8, 2024
33f86bb
Update test_petab_sciml.yml
FFroehlich Dec 8, 2024
5a84682
Update petab.py
FFroehlich Dec 8, 2024
97c7bbb
Update petab.py
FFroehlich Dec 8, 2024
ac79583
Update petab.py
FFroehlich Dec 8, 2024
4de63c4
Update ExampleJaxPEtab.ipynb
FFroehlich Dec 8, 2024
2fb392c
ignore test warning
FFroehlich Dec 8, 2024
4f3aff3
Update test_petab_sciml.yml
FFroehlich Dec 8, 2024
9c3fd4d
add hybridisation support
FFroehlich Dec 8, 2024
1349ddb
fix workflow
FFroehlich Dec 8, 2024
731b925
Merge branch 'develop' into jax_sciml
FFroehlich Dec 13, 2024
2ec62a5
Merge branch 'develop' into jax_sciml
FFroehlich Dec 19, 2024
4596dc4
update testsuite
FFroehlich Dec 19, 2024
bd103db
update after test refactor
FFroehlich Dec 19, 2024
6f9309c
Merge branch 'develop' into jax_sciml
FFroehlich Jan 27, 2025
2b6308d
fix hybridization
FFroehlich Jan 27, 2025
6089a95
Merge remote-tracking branch 'origin/jax_sciml' into jax_sciml
FFroehlich Jan 27, 2025
924aa3e
Merge branch 'develop' into jax_sciml
FFroehlich Apr 16, 2025
eaf3e09
update testsuite
FFroehlich Apr 16, 2025
4c6947e
update testsuite, some fixes
FFroehlich Apr 16, 2025
59c9be6
Update testsuite
FFroehlich Apr 16, 2025
6632a9c
fix #2687
FFroehlich Apr 17, 2025
f63f61b
Merge remote-tracking branch 'origin/fix_2687' into jax_sciml
FFroehlich Apr 17, 2025
6b133e2
spec updates
FFroehlich May 17, 2025
605adcb
Merge branch 'develop' into jax_sciml
FFroehlich Jun 16, 2025
7f5c3ad
updates for overhauled testsuite
FFroehlich Jun 16, 2025
cff3515
Merge branch 'develop' into jax_sciml
FFroehlich Jun 20, 2025
0348ee4
Update nn.py
FFroehlich Jun 20, 2025
381bf6d
Merge branch 'main' into jax_sciml
FFroehlich Jun 25, 2025
20d09f9
Merge branch 'main' into jax_sciml
FFroehlich Jun 29, 2025
b73cf60
Merge branch 'main' into jax_sciml
FFroehlich Jul 8, 2025
ceacc53
Merge branch 'main' into jax_sciml
FFroehlich Oct 7, 2025
f1ece15
Update petab_import.py
FFroehlich Oct 7, 2025
ec1ed55
Getting test_net petab-sciml tests to pass
BSnelling Sep 1, 2025
2e14198
Implementing features for a subset of ude petab_sciml test cases. Exc…
BSnelling Sep 1, 2025
d2137c3
update petab_sciml workflow - on branches and sciml install branch
BSnelling Sep 1, 2025
75a3630
updates to petab sciml workflow
BSnelling Sep 2, 2025
8a76e44
fix undef local var in jax tests
BSnelling Sep 2, 2025
374922c
frozen layers for RHS networks
BSnelling Sep 8, 2025
c2a386b
implement nns in the observable formula
BSnelling Sep 17, 2025
8bce416
tidy, refactor, generalise sciml test case implementations
BSnelling Sep 19, 2025
b322555
hybridization df in _petab_problem - makes JAXProblem jit-able
BSnelling Sep 30, 2025
dddc4c2
update frozen layer/arrays implementation
BSnelling Oct 3, 2025
5f5fb8c
update jax petab notebook
BSnelling Oct 6, 2025
ddc68fa
add h5py to docs deps
BSnelling Oct 6, 2025
9e744c7
fix sbml jax tests
BSnelling Oct 7, 2025
021ea45
missed rebased imports
BSnelling Oct 7, 2025
e630100
codecov maybe
BSnelling Oct 7, 2025
08e58a0
codecov - update cov file name
BSnelling Oct 10, 2025
55363e1
codecov - specify cov path
BSnelling Oct 10, 2025
6782793
enable zero params case
BSnelling Oct 14, 2025
3ad2309
doc build forward type definition workaround
BSnelling Oct 14, 2025
23227aa
simplify array input processing
BSnelling Oct 14, 2025
2641a80
Merge pull request #2947 from AMICI-dev/bes/jax_sciml
BSnelling Oct 14, 2025
0c59162
Merge branch 'main' into jax_sciml
FFroehlich Oct 15, 2025
5aacad8
bump versions, fixup notebook
FFroehlich Oct 15, 2025
a4089c3
Merge branch 'main' into jax_sciml
FFroehlich Oct 19, 2025
9009075
safety around nn_output_ids
BSnelling Oct 15, 2025
257e859
reinstate test
BSnelling Oct 24, 2025
b10b6f1
fix imports from amici.jax.nn
BSnelling Oct 24, 2025
da4fd83
Merge branch 'main' into jax_sciml
FFroehlich Oct 26, 2025
0b3bb26
skip petab tests with mapping df
FFroehlich Oct 28, 2025
94c407f
Merge branch 'main' into jax_sciml
FFroehlich Oct 28, 2025
fa95339
Merge branch 'main' into jax_sciml
FFroehlich Oct 29, 2025
f3f09ea
Apply suggestion from @dweindl
FFroehlich Oct 30, 2025
d30b710
Update python/sdist/amici/petab/petab_import.py
FFroehlich Oct 30, 2025
bfe1ad6
Update python/sdist/amici/petab/petab_import.py
FFroehlich Oct 30, 2025
f8b7b21
Merge branch 'main' into jax_sciml
FFroehlich Oct 30, 2025
548f754
review comments
FFroehlich Oct 30, 2025
b02507c
document hybridization table
FFroehlich Oct 30, 2025
090dfa1
update sciml repo
FFroehlich Oct 30, 2025
2b76193
refactor and add documentation to nn code
FFroehlich Oct 30, 2025
56cb561
print missing components
FFroehlich Oct 30, 2025
8e5952e
add tests
FFroehlich Oct 30, 2025
c5e8b0b
refactor _initialize_model_with_nominal_values
FFroehlich Oct 30, 2025
3a3ec71
fix doc, canonical spelling
FFroehlich Oct 31, 2025
775db53
Update python/sdist/amici/jax/model.py
FFroehlich Oct 31, 2025
f71f25f
Update python/sdist/amici/jax/nn.py
FFroehlich Oct 31, 2025
736de03
Update python/sdist/amici/jax/nn.py
FFroehlich Oct 31, 2025
01d1f66
Update python/sdist/amici/jax/petab.py
FFroehlich Oct 31, 2025
59e8dce
Update python/sdist/amici/petab/petab_import.py
FFroehlich Oct 31, 2025
f1bb8c5
Apply suggestion from @dweindl
FFroehlich Oct 31, 2025
b61273d
Apply suggestion from @dweindl
FFroehlich Oct 31, 2025
e9d1baf
Apply suggestion from @dweindl
FFroehlich Oct 31, 2025
8411dc6
pre-commit fixes
FFroehlich Oct 31, 2025
a7bd6ea
fixup
FFroehlich Oct 31, 2025
69069ea
update changelog
FFroehlich Oct 31, 2025
3672214
update testsuite, add support for cat
FFroehlich Oct 31, 2025
e90aade
Merge branch 'main' into jax_sciml
FFroehlich Oct 31, 2025
ed2bcd3
remove gitmodule
FFroehlich Oct 31, 2025
a1f1cab
refactor testsuite
FFroehlich Oct 31, 2025
f0b3c7e
remove initialization tests
FFroehlich Oct 31, 2025
675cee9
Update test_sciml.py
FFroehlich Oct 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/test_petab_sciml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: PEtab
on:
push:
branches:
- develop
- main
pull_request:
branches:
- main
- develop
- jax_sciml
merge_group:
workflow_dispatch:

jobs:
build:
name: PEtab SciML Testsuite

runs-on: ubuntu-latest

env:
ENABLE_GCOV_COVERAGE: TRUE

strategy:
matrix:
python-version: ["3.12"]

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v4
with:
fetch-depth: 20

# todo, update after https://github.com/sebapersson/petab_sciml_testsuite/issues/14 is merged
- name: Download PEtab SciML test suite
run: |
git clone --depth 1 --branch main \
https://github.com/FFroehlich/petab_sciml_testsuite \
tests/sciml/testsuite

- name: Install apt dependencies
uses: ./.github/actions/install-apt-dependencies

# install dependencies
- name: apt
run: |
sudo apt-get update \
&& sudo apt-get install -y python3-venv

- run: |
echo "${HOME}/.local/bin/" >> $GITHUB_PATH

# install AMICI
- name: Install python package
run: scripts/installAmiciSource.sh

- name: Install petab
run: |
source ./venv/bin/activate \
&& pip3 install wheel pytest shyaml pytest-cov

# retrieve test models
- name: Download and install PEtab SciML
run: |
source ./venv/bin/activate \
&& python -m pip install git+https://github.com/petab-dev/petab_sciml.git@main#subdirectory=src/python \


- name: Install petab
run: |
source ./venv/bin/activate \
&& python3 -m pip uninstall -y petab \
&& python3 -m pip install git+https://github.com/petab-dev/libpetab-python.git@sciml \

- name: Run PEtab SciML testsuite
run: |
source ./venv/bin/activate \
&& pytest --cov-report=xml:coverage_petab_sciml.xml \
--cov=amici tests/sciml/test_sciml.py

- name: Codecov
if: github.event_name == 'pull_request' || github.repository_owner == 'AMICI-dev'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage_petab_sciml.xml
flags: petab_sciml
fail_ci_if_error: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ models/model_calvetti/build/*

amici_models/

# PEtab SciML test suite (downloaded dynamically)
tests/sciml/testsuite/

simulate_model_*_hdf.m
simulate_model_*.m

Expand Down Expand Up @@ -196,3 +199,4 @@ debug/*
tests/benchmark_models/cache_fiddy/*
venv/*
.coverage
tests/sciml/models/*
Empty file added .gitmodules
Empty file.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni
This only works on shared file systems, as the solver state is stored in a
temporary HDF5 file.
* `amici.ExpData` is now picklable.
* Implemented support for the [PEtab SciML](https://github.com/PEtab-dev/petab_sciml)
extension for the JAX interface.
* The import function `sbml2amici`, `pysb2amici`, and `antimony2amici` now
return an instance of the generated model class if called with `compile=True`
(default).
Expand Down
6 changes: 6 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import exhale_multiproject_monkeypatch # noqa: F401

# need to import before setting typing.TYPE_CHECKING=True, fails otherwise

import amici
import pandas as pd # noqa: F401
import sympy as sp # noqa: F401
Expand Down Expand Up @@ -365,6 +366,11 @@ def install_doxygen():
"ExpDataPtrVector": ":class:`amici.amici.ExpData`",
}

# TODO: alias for forward type definition, remove after release of petab_sciml
autodoc_type_aliases = {
"NNModel": "petab_sciml.NNModel",
}


def process_docstring(app, what, name, obj, options, lines):
# only apply in the amici.amici module
Expand Down
26 changes: 15 additions & 11 deletions doc/examples/example_jax_petab/ExampleJaxPEtab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Access the results\n",
"results"
"# Define the simulation condition\n",
"simulation_condition = (\"model1_data1\",)\n",
"\n",
"# Access the results for the specified condition\n",
"ic = results[\"simulation_conditions\"].index(simulation_condition)\n",
"print(\"llh: \", results[\"llh\"][ic])\n",
"print(\"state variables: \", results[\"x\"][ic, :])"
]
},
{
Expand Down Expand Up @@ -356,7 +361,7 @@
"metadata": {},
"outputs": [],
"source": [
"grad._my"
"grad._my[ic, :]"
]
},
{
Expand Down Expand Up @@ -393,7 +398,7 @@
"nps = jax_problem._np_numeric[ic, :]\n",
"\n",
"# Load parameters for the specified condition\n",
"p = jax_problem.load_parameters(simulation_condition[0])\n",
"p = jax_problem.load_model_parameters(simulation_condition[0])\n",
"\n",
"\n",
"# Define a function to compute the gradient with respect to dynamic timepoints\n",
Expand Down Expand Up @@ -612,16 +617,16 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8382b0b2b68f49e",
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"# Profile gradient computation using forward sensitivity analysis\n",
"solver.set_sensitivity_order(amici.SensitivityOrder.first)\n",
"solver.set_sensitivity_method(amici.SensitivityMethod.forward)"
]
],
"id": "81fe95a6e7f613f1",
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand Down Expand Up @@ -687,8 +692,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
3 changes: 3 additions & 0 deletions doc/rtd_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ setuptools>=67.7.2
# https://github.com/pysb/pysb/pull/599
# for building the documentation, we don't care whether this fully works
git+https://github.com/pysb/pysb@0afeaab385e9a1d813ecf6fdaf0153f4b91358af
# For forward type definition in generate_equinox
git+https://github.com/PEtab-dev/petab_sciml.git@727d177fd3f85509d0bdcc278b672e9eeafd2384#subdirectory=src/python
matplotlib>=3.7.1
optax
nbsphinx
Expand All @@ -16,6 +18,7 @@ sphinx_rtd_theme>=1.2.0
petab[vis]>=0.2.0
sphinx-autodoc-typehints
ipython>=8.13.2
h5py>=3.14.0
breathe>=4.35.0
exhale>=0.3.7
-e git+https://github.com/mithro/sphinx-contrib-mithro#egg=sphinx-contrib-exhale-multiproject&subdirectory=sphinx-contrib-exhale-multiproject
Expand Down
6 changes: 6 additions & 0 deletions python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __init__(
allow_reinit_fixpar_initcond: bool | None = True,
generate_sensitivity_code: bool | None = True,
model_name: str | None = "model",
hybridization: dict | None = None,
):
"""
Generate AMICI C++ files for the DE provided to the constructor.
Expand Down Expand Up @@ -196,6 +197,10 @@ def __init__(

:param model_name:
name of the model to be used during code generation

:param hybridization:
dict representation of the hybridization information in the PEtab YAML file, see
https://petab-sciml.readthedocs.io/latest/format.html#problem-yaml-file
"""
set_log_level(logger, verbose)

Expand Down Expand Up @@ -237,6 +242,7 @@ def __init__(
self.allow_reinit_fixpar_initcond: bool = allow_reinit_fixpar_initcond
self._build_hints = set()
self.generate_sensitivity_code: bool = generate_sensitivity_code
self.hybridisation = hybridization

@log_execution_time("generating cpp code", logger)
def generate_model_code(self) -> None:
Expand Down
Loading
Loading