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

Fixes Blackjax SMC integration after bump #374

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencies:
- statsmodels
- pip:
- pymc>=5.16.1 # CI was failing to resolve
- blackjax
- blackjax>=1.2.3
- scikit-learn
19 changes: 12 additions & 7 deletions pymc_experimental/inference/smc/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jax.numpy as jnp
import numpy as np

from blackjax.smc import extend_params
from blackjax.smc.resampling import systematic
from pymc import draw, modelcontext, to_inference_data
from pymc.backends import NDArray
Expand Down Expand Up @@ -126,16 +127,20 @@ def sample_smc_blackjax(

if kernel == "HMC":
mcmc_kernel = blackjax.mcmc.hmc
mcmc_parameters = dict(
step_size=inner_kernel_params["step_size"],
inverse_mass_matrix=jnp.eye(posterior_dimensions),
num_integration_steps=inner_kernel_params["integration_steps"],
mcmc_parameters = extend_params(
dict(
step_size=inner_kernel_params["step_size"],
inverse_mass_matrix=jnp.eye(posterior_dimensions),
num_integration_steps=inner_kernel_params["integration_steps"],
)
)
elif kernel == "NUTS":
mcmc_kernel = blackjax.mcmc.nuts
mcmc_parameters = dict(
step_size=inner_kernel_params["step_size"],
inverse_mass_matrix=jnp.eye(posterior_dimensions),
mcmc_parameters = extend_params(
dict(
step_size=inner_kernel_params["step_size"],
inverse_mass_matrix=jnp.eye(posterior_dimensions),
)
)
else:
raise ValueError(f"Invalid kernel {kernel}, valid options are 'HMC' and 'NUTS'")
Expand Down
1 change: 0 additions & 1 deletion tests/test_blackjax_smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def fast_model():
("NUTS", False, {"step_size": 0.1}),
],
)
@pytest.mark.xfail(reason="Still need to investigate")
def test_sample_smc_blackjax(kernel, check_for_integration_steps, inner_kernel_params):
"""
When running the two gaussians model
Expand Down
Loading