Skip to content

Filter warning for batched_dot until we change it #455

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

Merged
merged 3 commits into from
Apr 12, 2025
Merged
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
22 changes: 13 additions & 9 deletions pymc_extras/inference/pathfinder/pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ def bfgs_sample_dense(

logdet = 2.0 * pt.sum(pt.log(pt.abs(pt.diagonal(Lchol, axis1=-2, axis2=-1))), axis=-1)

mu = x - pt.batched_dot(H_inv, g)
with _warnings.catch_warnings():
_warnings.simplefilter("ignore", category=FutureWarning)
mu = x - pt.batched_dot(H_inv, g)

phi = pt.matrix_transpose(
# (L, N, 1)
Expand Down Expand Up @@ -572,14 +574,16 @@ def bfgs_sample_sparse(
logdet += pt.sum(pt.log(alpha), axis=-1)

# NOTE: changed the sign from "x + " to "x -" of the expression to match Stan which differs from Zhang et al., (2022). same for dense version.
mu = x - (
# (L, N), (L, N) -> (L, N)
pt.batched_dot(alpha_diag, g)
# beta @ gamma @ beta.T
# (L, N, 2J), (L, 2J, 2J), (L, 2J, N) -> (L, N, N)
# (L, N, N), (L, N) -> (L, N)
+ pt.batched_dot((beta @ gamma @ pt.matrix_transpose(beta)), g)
)
with _warnings.catch_warnings():
_warnings.simplefilter("ignore", category=FutureWarning)
mu = x - (
# (L, N), (L, N) -> (L, N)
pt.batched_dot(alpha_diag, g)
# beta @ gamma @ beta.T
# (L, N, 2J), (L, 2J, 2J), (L, 2J, N) -> (L, N, N)
# (L, N, N), (L, N) -> (L, N)
+ pt.batched_dot((beta @ gamma @ pt.matrix_transpose(beta)), g)
)

phi = pt.matrix_transpose(
# (L, N, 1)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import pymc as pm
import pytest

pytestmark = pytest.mark.filterwarnings("ignore:compile_pymc was renamed to compile:FutureWarning")
pytestmark = pytest.mark.filterwarnings(
"ignore:compile_pymc was renamed to compile:FutureWarning",
)

import pymc_extras as pmx

Expand Down