aspire-inference 0.1.0a9__tar.gz → 0.1.0a11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/PKG-INFO +23 -4
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/README.md +20 -2
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/PKG-INFO +23 -4
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/SOURCES.txt +2 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/requires.txt +2 -1
- aspire_inference-0.1.0a11/docs/checkpointing.rst +88 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/conf.py +1 -1
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/index.rst +9 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/installation.rst +5 -1
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/pyproject.toml +2 -1
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/aspire.py +356 -4
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/torch/flows.py +1 -1
- aspire_inference-0.1.0a11/src/aspire/samplers/base.py +238 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/base.py +133 -48
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/blackjax.py +8 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/emcee.py +8 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/minipcn.py +26 -6
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samples.py +21 -15
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/utils.py +157 -4
- aspire_inference-0.1.0a11/tests/integration_tests/test_checkpointing.py +88 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_samples.py +1 -1
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_utils.py +14 -1
- aspire_inference-0.1.0a9/src/aspire/samplers/base.py +0 -94
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/lint.yml +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/publish.yml +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/tests.yml +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.gitignore +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.pre-commit-config.yaml +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/LICENSE +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/dependency_links.txt +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/top_level.txt +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/Makefile +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/entry_points.rst +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/examples.rst +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/multiprocessing.rst +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/recipes.rst +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/requirements.txt +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/user_guide.rst +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/basic_example.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/blackjax_smc_example.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/smc_example.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/readthedocs.yml +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/setup.cfg +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/base.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/flows.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/utils.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/torch/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/history.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/plot.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/importance.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/mcmc.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/__init__.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/transforms.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/conftest.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/integration_tests/conftest.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/integration_tests/test_integration.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_flows_core.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_jax_flows/test_flowjax_flows.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_torch_flows/test_zuko_flows.py +0 -0
- {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_transforms.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aspire-inference
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a11
|
|
4
4
|
Summary: Accelerate Sequential Posterior Inference via REuse
|
|
5
5
|
Author-email: "Michael J. Williams" <michaeljw1@googlemail.com>
|
|
6
6
|
License: MIT
|
|
@@ -26,7 +26,8 @@ Requires-Dist: torch; extra == "torch"
|
|
|
26
26
|
Requires-Dist: zuko; extra == "torch"
|
|
27
27
|
Requires-Dist: tqdm; extra == "torch"
|
|
28
28
|
Provides-Extra: minipcn
|
|
29
|
-
Requires-Dist: minipcn; extra == "minipcn"
|
|
29
|
+
Requires-Dist: minipcn[array-api]>=0.2.0a3; extra == "minipcn"
|
|
30
|
+
Requires-Dist: orng; extra == "minipcn"
|
|
30
31
|
Provides-Extra: emcee
|
|
31
32
|
Requires-Dist: emcee; extra == "emcee"
|
|
32
33
|
Provides-Extra: blackjax
|
|
@@ -49,10 +50,28 @@ aspire is a framework for reusing existing posterior samples to obtain new resul
|
|
|
49
50
|
|
|
50
51
|
## Installation
|
|
51
52
|
|
|
52
|
-
aspire can be installed from PyPI using `pip
|
|
53
|
+
aspire can be installed from PyPI using `pip`. By default, you need to install
|
|
54
|
+
one of the backends for the normalizing flows, either `torch` or `jax`.
|
|
55
|
+
We also recommend installing `minipcn` if using the `smc` sampler:
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
**Torch**
|
|
59
|
+
|
|
60
|
+
We recommend installing `torch` manually to ensure correct CPU/CUDA versions are
|
|
61
|
+
installed. See the [PyTorch installation instructions](https://pytorch.org/)
|
|
62
|
+
for more details.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pip install aspire-inference[torch,minipcn]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Jax**:
|
|
69
|
+
|
|
70
|
+
We recommend install `jax` manually to ensure the correct GPU/CUDA versions
|
|
71
|
+
are installed. See the [jax documentation for details](https://docs.jax.dev/en/latest/installation.html)
|
|
53
72
|
|
|
54
73
|
```
|
|
55
|
-
pip install aspire-inference
|
|
74
|
+
pip install aspire-inference[jax,minipcn]
|
|
56
75
|
```
|
|
57
76
|
|
|
58
77
|
**Important:** the name of `aspire` on PyPI is `aspire-inference` but once installed
|
|
@@ -10,10 +10,28 @@ aspire is a framework for reusing existing posterior samples to obtain new resul
|
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
aspire can be installed from PyPI using `pip
|
|
13
|
+
aspire can be installed from PyPI using `pip`. By default, you need to install
|
|
14
|
+
one of the backends for the normalizing flows, either `torch` or `jax`.
|
|
15
|
+
We also recommend installing `minipcn` if using the `smc` sampler:
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
**Torch**
|
|
19
|
+
|
|
20
|
+
We recommend installing `torch` manually to ensure correct CPU/CUDA versions are
|
|
21
|
+
installed. See the [PyTorch installation instructions](https://pytorch.org/)
|
|
22
|
+
for more details.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
pip install aspire-inference[torch,minipcn]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Jax**:
|
|
29
|
+
|
|
30
|
+
We recommend install `jax` manually to ensure the correct GPU/CUDA versions
|
|
31
|
+
are installed. See the [jax documentation for details](https://docs.jax.dev/en/latest/installation.html)
|
|
14
32
|
|
|
15
33
|
```
|
|
16
|
-
pip install aspire-inference
|
|
34
|
+
pip install aspire-inference[jax,minipcn]
|
|
17
35
|
```
|
|
18
36
|
|
|
19
37
|
**Important:** the name of `aspire` on PyPI is `aspire-inference` but once installed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aspire-inference
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a11
|
|
4
4
|
Summary: Accelerate Sequential Posterior Inference via REuse
|
|
5
5
|
Author-email: "Michael J. Williams" <michaeljw1@googlemail.com>
|
|
6
6
|
License: MIT
|
|
@@ -26,7 +26,8 @@ Requires-Dist: torch; extra == "torch"
|
|
|
26
26
|
Requires-Dist: zuko; extra == "torch"
|
|
27
27
|
Requires-Dist: tqdm; extra == "torch"
|
|
28
28
|
Provides-Extra: minipcn
|
|
29
|
-
Requires-Dist: minipcn; extra == "minipcn"
|
|
29
|
+
Requires-Dist: minipcn[array-api]>=0.2.0a3; extra == "minipcn"
|
|
30
|
+
Requires-Dist: orng; extra == "minipcn"
|
|
30
31
|
Provides-Extra: emcee
|
|
31
32
|
Requires-Dist: emcee; extra == "emcee"
|
|
32
33
|
Provides-Extra: blackjax
|
|
@@ -49,10 +50,28 @@ aspire is a framework for reusing existing posterior samples to obtain new resul
|
|
|
49
50
|
|
|
50
51
|
## Installation
|
|
51
52
|
|
|
52
|
-
aspire can be installed from PyPI using `pip
|
|
53
|
+
aspire can be installed from PyPI using `pip`. By default, you need to install
|
|
54
|
+
one of the backends for the normalizing flows, either `torch` or `jax`.
|
|
55
|
+
We also recommend installing `minipcn` if using the `smc` sampler:
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
**Torch**
|
|
59
|
+
|
|
60
|
+
We recommend installing `torch` manually to ensure correct CPU/CUDA versions are
|
|
61
|
+
installed. See the [PyTorch installation instructions](https://pytorch.org/)
|
|
62
|
+
for more details.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pip install aspire-inference[torch,minipcn]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Jax**:
|
|
69
|
+
|
|
70
|
+
We recommend install `jax` manually to ensure the correct GPU/CUDA versions
|
|
71
|
+
are installed. See the [jax documentation for details](https://docs.jax.dev/en/latest/installation.html)
|
|
53
72
|
|
|
54
73
|
```
|
|
55
|
-
pip install aspire-inference
|
|
74
|
+
pip install aspire-inference[jax,minipcn]
|
|
56
75
|
```
|
|
57
76
|
|
|
58
77
|
**Important:** the name of `aspire` on PyPI is `aspire-inference` but once installed
|
{aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/SOURCES.txt
RENAMED
|
@@ -13,6 +13,7 @@ aspire_inference.egg-info/dependency_links.txt
|
|
|
13
13
|
aspire_inference.egg-info/requires.txt
|
|
14
14
|
aspire_inference.egg-info/top_level.txt
|
|
15
15
|
docs/Makefile
|
|
16
|
+
docs/checkpointing.rst
|
|
16
17
|
docs/conf.py
|
|
17
18
|
docs/entry_points.rst
|
|
18
19
|
docs/examples.rst
|
|
@@ -53,6 +54,7 @@ tests/test_samples.py
|
|
|
53
54
|
tests/test_transforms.py
|
|
54
55
|
tests/test_utils.py
|
|
55
56
|
tests/integration_tests/conftest.py
|
|
57
|
+
tests/integration_tests/test_checkpointing.py
|
|
56
58
|
tests/integration_tests/test_integration.py
|
|
57
59
|
tests/test_flows/test_flows_core.py
|
|
58
60
|
tests/test_flows/test_jax_flows/test_flowjax_flows.py
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Checkpointing and Resuming
|
|
2
|
+
==========================
|
|
3
|
+
|
|
4
|
+
Aspire provides a few simple patterns to resume long runs.
|
|
5
|
+
|
|
6
|
+
Saving checkpoints while sampling
|
|
7
|
+
---------------------------------
|
|
8
|
+
|
|
9
|
+
- Pass ``checkpoint_path`` (an HDF5 file) to :py:meth:`aspire.Aspire.sample_posterior`
|
|
10
|
+
to write checkpoints as the sampler runs. Use ``checkpoint_every`` to control
|
|
11
|
+
frequency and ``checkpoint_save_config/flow`` to control what metadata is saved.
|
|
12
|
+
- For a convenience wrapper, wrap your sampling in
|
|
13
|
+
``with aspire.auto_checkpoint("run.h5", every=1): ...``. Inside the context,
|
|
14
|
+
``sample_posterior`` will default to checkpointing to that file, and the config/flow
|
|
15
|
+
will be updated as needed.
|
|
16
|
+
|
|
17
|
+
What gets saved
|
|
18
|
+
^^^^^^^^^^^^^^^
|
|
19
|
+
|
|
20
|
+
- The sampler stores checkpoints under ``/checkpoint/state`` in the HDF5 file.
|
|
21
|
+
- Aspire writes ``/aspire_config`` (with ``sampler_type`` and ``sampler_config``) and
|
|
22
|
+
``/flow``. If these already exist, they are overwritten when saving.
|
|
23
|
+
|
|
24
|
+
Resuming from a file
|
|
25
|
+
--------------------
|
|
26
|
+
|
|
27
|
+
- Use :py:meth:`aspire.Aspire.resume_from_file` to rebuild an Aspire instance and flow
|
|
28
|
+
from a checkpoint file:
|
|
29
|
+
|
|
30
|
+
.. code-block:: python
|
|
31
|
+
|
|
32
|
+
aspire = Aspire.resume_from_file(
|
|
33
|
+
"run.h5",
|
|
34
|
+
log_likelihood=log_likelihood,
|
|
35
|
+
log_prior=log_prior,
|
|
36
|
+
)
|
|
37
|
+
# Optionally continue checkpointing to the same file
|
|
38
|
+
with aspire.auto_checkpoint("run.h5", every=1):
|
|
39
|
+
samples = aspire.sample_posterior()
|
|
40
|
+
|
|
41
|
+
- ``resume_from_file`` loads config, flow, and the last checkpoint (if present), and
|
|
42
|
+
primes the instance to resume sampling; you can still override sampler kwargs when
|
|
43
|
+
calling ``sample_posterior``.
|
|
44
|
+
|
|
45
|
+
Manual resume via ``sample_posterior`` args
|
|
46
|
+
-------------------------------------------
|
|
47
|
+
|
|
48
|
+
- If you have a checkpoint blob (bytes or dict) already, you can pass it directly:
|
|
49
|
+
|
|
50
|
+
.. code-block:: python
|
|
51
|
+
|
|
52
|
+
samples = aspire.sample_posterior(
|
|
53
|
+
n_samples=...,
|
|
54
|
+
sampler="smc",
|
|
55
|
+
resume_from=checkpoint_bytes_or_dict,
|
|
56
|
+
checkpoint_path="run.h5", # optional: keep writing checkpoints
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
- To resume from a file without using ``resume_from_file``, load the checkpoint bytes
|
|
60
|
+
and flow yourself, then call ``sample_posterior``:
|
|
61
|
+
|
|
62
|
+
.. code-block:: python
|
|
63
|
+
|
|
64
|
+
from aspire.utils import AspireFile
|
|
65
|
+
|
|
66
|
+
aspire = Aspire(..., flow_backend="zuko")
|
|
67
|
+
with AspireFile("run.h5", "r") as f:
|
|
68
|
+
aspire.load_flow(f, path="flow")
|
|
69
|
+
# Standard layout is /checkpoint/state; adjust if you used a different path
|
|
70
|
+
checkpoint_bytes = f["checkpoint"]["state"][...].tobytes()
|
|
71
|
+
samples = aspire.sample_posterior(
|
|
72
|
+
n_samples=..., sampler="smc", resume_from="run.h5"
|
|
73
|
+
# or resume_from=checkpoint_bytes if you prefer to pass bytes directly
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
Notes and tips
|
|
77
|
+
--------------
|
|
78
|
+
|
|
79
|
+
- Checkpoint files must be HDF5 (``.h5``/``.hdf5``).
|
|
80
|
+
- If a checkpoint is missing in the file (e.g., sampling never wrote one), the flow
|
|
81
|
+
and config are still loaded; you can simply start sampling again and checkpointing
|
|
82
|
+
will continue to the same file.
|
|
83
|
+
- For manual control, you can always call ``save_config`` / ``save_flow`` yourself
|
|
84
|
+
on an :class:`aspire.utils.AspireFile`.
|
|
85
|
+
- SMC samplers also accept a custom ``checkpoint_callback`` and ``checkpoint_every`` if
|
|
86
|
+
you want full control over how checkpoints are persisted or inspected. Provide a
|
|
87
|
+
callable that accepts the checkpoint state dict; from there you can, for example,
|
|
88
|
+
serialize to another format or push to remote storage.
|
|
@@ -57,7 +57,16 @@ examples, and the complete API reference.
|
|
|
57
57
|
|
|
58
58
|
installation
|
|
59
59
|
user_guide
|
|
60
|
+
checkpointing
|
|
60
61
|
recipes
|
|
61
62
|
multiprocessing
|
|
62
63
|
examples
|
|
63
64
|
entry_points
|
|
65
|
+
API Reference </autoapi/aspire/index>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
.. toctree::
|
|
69
|
+
:maxdepth: 2
|
|
70
|
+
:caption: Related Packages
|
|
71
|
+
|
|
72
|
+
aspire-bilby <https://aspire.readthedocs.io/projects/aspire-bilby/en/latest/>
|
|
@@ -14,7 +14,11 @@ Install the library from PyPI (note the published name):
|
|
|
14
14
|
|
|
15
15
|
$ python -m pip install aspire-inference
|
|
16
16
|
|
|
17
|
-
The installed distribution exposes the ``aspire`` import namespace.
|
|
17
|
+
The installed distribution exposes the ``aspire`` import namespace. By default,
|
|
18
|
+
this doesn't include any optional dependencies beyond the core ones listed above.
|
|
19
|
+
We recommend installing with at least one backend for normalizing flows, e.g.
|
|
20
|
+
``torch`` (PyTorch + ``zuko``) or ``jax`` (JAX + ``flowjax``).
|
|
21
|
+
and optionally the ``minipcn`` SMC kernel.
|
|
18
22
|
|
|
19
23
|
Optional extras
|
|
20
24
|
---------------
|