Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZarrTrace #7540

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:

- |
tests/backends/test_mcbackend.py
tests/backends/test_zarr.py
tests/distributions/test_truncated.py
tests/logprob/test_abstract.py
tests/logprob/test_basic.py
Expand Down Expand Up @@ -284,6 +285,7 @@ jobs:

- |
tests/backends/test_arviz.py
tests/backends/test_zarr.py
tests/variational/test_updates.py
fail-fast: false
runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions conda-envs/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
- scipy>=1.4.1
- typing-extensions>=3.7.4
- threadpoolctl>=3.1.0
- zarr>=2.5.0,<3
# Extra dependencies for dev, testing and docs build
- ipython>=7.16
- jax
Expand Down
1 change: 1 addition & 0 deletions conda-envs/environment-jax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- cachetools>=4.2.1
- cloudpickle
- h5py>=2.7
- zarr>=2.5.0,<3
# Jaxlib version must not be greater than jax version!
- blackjax>=1.2.2
- jax>=0.4.28
Expand Down
1 change: 1 addition & 0 deletions conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
- scipy>=1.4.1
- typing-extensions>=3.7.4
- threadpoolctl>=3.1.0
- zarr>=2.5.0,<3
# Extra dependencies for testing
- ipython>=7.16
- pre-commit>=2.8.0
Expand Down
1 change: 1 addition & 0 deletions conda-envs/windows-environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
- scipy>=1.4.1
- typing-extensions>=3.7.4
- threadpoolctl>=3.1.0
- zarr>=2.5.0,<3
# Extra dependencies for dev, testing and docs build
- ipython>=7.16
- myst-nb<=1.0.0
Expand Down
1 change: 1 addition & 0 deletions conda-envs/windows-environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
- scipy>=1.4.1
- typing-extensions>=3.7.4
- threadpoolctl>=3.1.0
- zarr>=2.5.0,<3
# Extra dependencies for testing
- ipython>=7.16
- pre-commit>=2.8.0
Expand Down
17 changes: 15 additions & 2 deletions pymc/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
from pymc.backends.arviz import predictions_to_inference_data, to_inference_data
from pymc.backends.base import BaseTrace, IBaseTrace
from pymc.backends.ndarray import NDArray
from pymc.backends.zarr import ZarrTrace
from pymc.model import Model
from pymc.step_methods.compound import BlockedStep, CompoundStep

Expand Down Expand Up @@ -118,15 +119,27 @@ def _init_trace(

def init_traces(
*,
backend: TraceOrBackend | None,
backend: TraceOrBackend | ZarrTrace | None,
chains: int,
expected_length: int,
step: BlockedStep | CompoundStep,
initial_point: Mapping[str, np.ndarray],
initial_point: dict[str, np.ndarray],
model: Model,
trace_vars: list[TensorVariable] | None = None,
tune: int = 0,
) -> tuple[RunType | None, Sequence[IBaseTrace]]:
"""Initialize a trace recorder for each chain."""
if isinstance(backend, ZarrTrace):
backend.init_trace(
chains=chains,
draws=expected_length - tune,
tune=tune,
step=step,
model=model,
vars=trace_vars,
test_point=initial_point,
)
return None, backend.straces
if HAS_MCB and isinstance(backend, Backend):
return init_chain_adapters(
backend=backend,
Expand Down
Loading
Loading