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.
Files changed (64) hide show
  1. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/PKG-INFO +23 -4
  2. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/README.md +20 -2
  3. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/PKG-INFO +23 -4
  4. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/SOURCES.txt +2 -0
  5. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/requires.txt +2 -1
  6. aspire_inference-0.1.0a11/docs/checkpointing.rst +88 -0
  7. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/conf.py +1 -1
  8. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/index.rst +9 -0
  9. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/installation.rst +5 -1
  10. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/pyproject.toml +2 -1
  11. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/aspire.py +356 -4
  12. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/torch/flows.py +1 -1
  13. aspire_inference-0.1.0a11/src/aspire/samplers/base.py +238 -0
  14. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/base.py +133 -48
  15. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/blackjax.py +8 -0
  16. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/emcee.py +8 -0
  17. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/minipcn.py +26 -6
  18. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samples.py +21 -15
  19. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/utils.py +157 -4
  20. aspire_inference-0.1.0a11/tests/integration_tests/test_checkpointing.py +88 -0
  21. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_samples.py +1 -1
  22. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_utils.py +14 -1
  23. aspire_inference-0.1.0a9/src/aspire/samplers/base.py +0 -94
  24. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/lint.yml +0 -0
  25. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/publish.yml +0 -0
  26. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.github/workflows/tests.yml +0 -0
  27. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.gitignore +0 -0
  28. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/.pre-commit-config.yaml +0 -0
  29. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/LICENSE +0 -0
  30. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/dependency_links.txt +0 -0
  31. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/aspire_inference.egg-info/top_level.txt +0 -0
  32. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/Makefile +0 -0
  33. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/entry_points.rst +0 -0
  34. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/examples.rst +0 -0
  35. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/multiprocessing.rst +0 -0
  36. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/recipes.rst +0 -0
  37. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/requirements.txt +0 -0
  38. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/docs/user_guide.rst +0 -0
  39. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/basic_example.py +0 -0
  40. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/blackjax_smc_example.py +0 -0
  41. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/examples/smc_example.py +0 -0
  42. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/readthedocs.yml +0 -0
  43. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/setup.cfg +0 -0
  44. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/__init__.py +0 -0
  45. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/__init__.py +0 -0
  46. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/base.py +0 -0
  47. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/__init__.py +0 -0
  48. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/flows.py +0 -0
  49. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/jax/utils.py +0 -0
  50. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/flows/torch/__init__.py +0 -0
  51. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/history.py +0 -0
  52. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/plot.py +0 -0
  53. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/__init__.py +0 -0
  54. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/importance.py +0 -0
  55. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/mcmc.py +0 -0
  56. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/samplers/smc/__init__.py +0 -0
  57. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/src/aspire/transforms.py +0 -0
  58. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/conftest.py +0 -0
  59. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/integration_tests/conftest.py +0 -0
  60. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/integration_tests/test_integration.py +0 -0
  61. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_flows_core.py +0 -0
  62. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_jax_flows/test_flowjax_flows.py +0 -0
  63. {aspire_inference-0.1.0a9 → aspire_inference-0.1.0a11}/tests/test_flows/test_torch_flows/test_zuko_flows.py +0 -0
  64. {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.0a9
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.0a9
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
@@ -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
@@ -16,7 +16,8 @@ jaxlib
16
16
  flowjax
17
17
 
18
18
  [minipcn]
19
- minipcn
19
+ minipcn[array-api]>=0.2.0a3
20
+ orng
20
21
 
21
22
  [scipy]
22
23
  scipy
@@ -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.
@@ -46,7 +46,7 @@ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
46
46
 
47
47
  autoapi_type = "python"
48
48
  autoapi_dirs = ["../src/aspire/"]
49
- autoapi_add_toctree_entry = True
49
+ autoapi_add_toctree_entry = False
50
50
  autoapi_options = [
51
51
  "members",
52
52
  "imported-members",
@@ -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
  ---------------
@@ -39,7 +39,8 @@ torch = [
39
39
  "tqdm",
40
40
  ]
41
41
  minipcn = [
42
- "minipcn",
42
+ "minipcn[array-api]>=0.2.0a3",
43
+ "orng",
43
44
  ]
44
45
  emcee = [
45
46
  "emcee",