Open
Conversation
1a4bf41 to
2c59b8c
Compare
2c59b8c to
e7f4940
Compare
317229d to
9a064f0
Compare
9a064f0 to
7db53a1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v6 #8243 +/- ##
=====================================
Coverage ? 88.35%
=====================================
Files ? 124
Lines ? 19962
Branches ? 0
=====================================
Hits ? 17638
Misses ? 2324
Partials ? 0
🚀 New features to boost your workflow:
|
3bfe4fb to
ff4a930
Compare
Member
|
Truncation test failing. Bot came up with this MWE, I didn't have time to check, suspect the issue is in PyMC not PyTensor. """Pytensor scan + until + OpFromGraph (with rng inputs) drops rng updates.
Without ``until`` the same scan body propagates the rng updates correctly
across iterations. With ``until`` the inner OpFromGraph's rng inputs are
stuck on their initial values and every iteration produces identical draws.
"""
import warnings
warnings.simplefilter("ignore")
import numpy as np
import pytensor
import pytensor.tensor as pt
from pytensor.scan import scan, until
from pymc import HalfNormal, LogNormal, Mixture, CustomDist
from pymc.pytensorf import collect_default_updates
def mix_dist_fn(size):
return Mixture.dist(
w=[0.3, 0.7],
comp_dists=[HalfNormal.dist(), LogNormal.dist()],
shape=size,
)
x = CustomDist.dist(dist=mix_dist_fn, shape=(5,))
def loop_fn_no_until(prev, *rngs):
new = x.owner.op.make_node(*rngs).default_output()
return new, collect_default_updates(new)
def loop_fn_until(prev, *rngs):
new = x.owner.op.make_node(*rngs).default_output()
return new, collect_default_updates(new), until(pt.all(new < -100))
print("=== no until ===")
out, updates = scan(
loop_fn_no_until,
outputs_info=[pt.zeros((5,))],
non_sequences=list(x.owner.inputs),
n_steps=3,
strict=True,
)
print(pytensor.function([], out, updates=updates)())
print("=== with until ===")
out, updates = scan(
loop_fn_until,
outputs_info=[pt.zeros((5,))],
non_sequences=list(x.owner.inputs),
n_steps=3,
strict=True,
)
print(pytensor.function([], out, updates=updates)()) |
This was referenced Apr 9, 2026
Member
|
This is blocked on pymc-devs/pytensor#2039 |
trust_input=True requires ndarray storage for 0-d inputs. The ADVI init paths were yielding numpy scalars; wrap with np.asarray.
Add regression test that all RNGs are truly updated by the inner step function
b89e6f6 to
c3a9400
Compare
The xfail was added during the aeppl integration (0a172c8) because the analytical log_jac_det and the numerical det(jacobian) baseline diverged by ~3e-5. Investigation shows the analytical log_jac_det is correct and the numerical baseline is the imprecise side. For the worst-case input y=[2.1, 2.1, 2.1, 2.1], mpmath (50 digits) confirms: true log|det(J)|: -51.328128121070321 analytical log_jac_det: -51.328128121070336 (error: 1.4e-14) numerical det(jacobian): -51.328096462874562 (error: 3.2e-05) Root cause: PyTensor's autodiff computes expit'(z) as expit(z) * (1 - expit(z)). For large z (e.g., 26.6), expit(z) rounds to ~1.0 and the subtraction 1 - expit(z) loses precision. A more stable form would be expit(z) * expit(-z). Reproducible with mpmath: from mpmath import mp, mpf, log, exp, matrix, det mp.dps = 50 y = [mpf('2.1')] * 4 def expit(z): return 1 / (1 + exp(-z)) v = [y[0]] for i in range(1, 4): v.append(v[-1] + exp(y[i])) J = matrix(4, 4) for i in range(4): sp = expit(v[i]) * (1 - expit(v[i])) for j in range(i + 1): J[i, j] = sp * (1 if j == 0 else exp(y[j])) print(float(log(abs(det(J))))) # -51.328128121070321 Closes #5088 (last remaining item).
c3a9400 to
d9c48b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.