Flow adaptation fits much worse when the posterior scale is small
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start by running the included 50-dimensional normal example and compare fisher_distance and final step size at the two covariance scales. The payload does not name implementation files or tests, and says the cause is unknown, so trace how adaptation="flow" and with_transform_adapt handle scale changes. Done means the flow fits comparably at small and unit scales while sampling still recovers the target statistics.
Written by the indexing model from the issue text.
Description
adaptation="flow" fits the flow much worse when the posterior's scale is small, even with x64 enabled. On a correlated 50-dimensional normal, the mean fisher distance is 0.025 at unit scale and 2090 after scaling the covariance by 1e-8, and the final step size drops from 1.62 to 0.066. Sampling still recovers the means and standard deviations to within about 15%, and the cause isn't established.
import jax
jax.config.update("jax_enable_x64", True)
import numpy as np
import pymc as pm
import nutpie
rng = np.random.default_rng(0)
dim = 50
factor = rng.normal(size=(dim, dim)) / np.sqrt(dim)
correlation = factor @ factor.T + 0.1 * np.eye(dim)
for scale in [1.0, 1e-4]:
with pm.Model() as model:
pm.MvNormal("x", mu=np.zeros(dim), cov=correlation * scale**2)
compiled = nutpie.compile_pymc_model(model, backend="jax", gradient_backend="jax")
trace = nutpie.sample(compiled.with_transform_adapt(num_layers=4), adaptation="flow",
chains=1, draws=500, seed=1, progress_bar=False)
print(f"scale={scale:.0e} fisher_distance={float(trace.sample_stats['fisher_distance'].mean()):.3f}")
# scale=1e+00 fisher_distance=0.025
# scale=1e-04 fisher_distance=2090.241
- Dominant language
- Python
- Stars
- 214
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pymc-devs/nutpie
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
with_data fails with a list on the jax backendPossibly taken @RaphaelFakhri claimed this 22 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
All issues in pymc-devs/nutpie
Similar issues
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
kornia/kornia-rs#1416 · 1 comment ·
Maintainers usually reply within 2 days
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PolicyEngine/ai-inequality#64 ·
Maintainers usually reply within 1 day
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timePossibly taken @PabloRoque claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
pymc-devs/pymc-extras#839 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day