Skip to content

Conversation

@rlouf
Copy link
Member

@rlouf rlouf commented Apr 21, 2022

Since #55 the inner scans do not use default_updates but instead return the inner updates following scan's inner function semantics. In this PR we make kernel return inner updates as well.

@rlouf
Copy link
Member Author

rlouf commented Apr 21, 2022

Despite the seemingly minimal change,test_nuts_mcse does not pass anymore which is an indication that something is seriously wrong.

@rlouf rlouf force-pushed the return-internal-updates branch from 33addff to e006a4e Compare April 21, 2022 14:39
@rlouf rlouf self-assigned this Apr 21, 2022
@rlouf rlouf added the enhancement New feature or request label Apr 21, 2022
@rlouf rlouf force-pushed the return-internal-updates branch from e006a4e to 84c4ca2 Compare April 21, 2022 14:40
Copy link
Member

@brandonwillard brandonwillard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be anything wrong with the updates-related changes.

Despite the seemingly minimal change,test_nuts_mcse does not pass anymore which is an indication that something is seriously wrong.

I can reproduce the CI error in test_nuts, but test_nuts_mcse passes locally. Changing the RNG seed in test_nuts affects the pass/fail results significantly, yet the values are all within at least a +-1 range of the "true" values.

It's not clear to me why those step size, mass matrix values, etc., should guarantee errors within the test ranges, so there's not much more I can say than that the tests look flaky.

Also, the function evaluation time seem rather long for these toy problems; are there any tests like these that check the trajectory statistics as well? If not, it looks like we need them.

@rlouf
Copy link
Member Author

rlouf commented Apr 22, 2022

I was thinking about getting rid of all non-mcse tests. As you said, they're flaky as a way to assess the correctness of samples and they take a long time to run.

@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

Merging #56 (b0104d9) into main (46218ef) will not change coverage.
The diff coverage is 100.00%.

❗ Current head b0104d9 differs from pull request most recent head 56ee318. Consider uploading reports for the commit 56ee318 to get more accurate results

@@            Coverage Diff            @@
##              main       #56   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          461       461           
  Branches        24        24           
=========================================
  Hits           461       461           
Impacted Files Coverage Δ
aehmc/hmc.py 100.00% <100.00%> (ø)
aehmc/nuts.py 100.00% <100.00%> (ø)
aehmc/step_size.py 100.00% <100.00%> (ø)
aehmc/trajectory.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46218ef...56ee318. Read the comment docs.

Copy link
Member

@brandonwillard brandonwillard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's squash the updates-related commits together, and the same for the test change commits.

@brandonwillard
Copy link
Member

Also, we can keep the old tests, but mark them as xfail (or skip) until the setup/conditions are made more stable.

@rlouf rlouf force-pushed the return-internal-updates branch 2 times, most recently from e0c58ac to 43a052d Compare April 25, 2022 07:01
@rlouf rlouf requested a review from brandonwillard April 25, 2022 16:38
return ess


def compute_mcse(samples, true_param):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this function name still apply; it doesn't appear to be returning a standard error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, renamed it.

def compute_mcse(samples, true_param):
"""Compute the probability of getting an error more extreme
than the one we observe assuming the samples are really drawn
from the target distirbution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this assuming a normal target distribution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

],
non_sequences=0.5,
n_steps=2000,
non_sequences=1.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not pass with a smaller step size?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. Here I adapted the step size manually to get an average acceptance probability of 0.8 (target in the window adaptation warmup); it also runs slightly faster.

@rlouf rlouf force-pushed the return-internal-updates branch from 43a052d to b0104d9 Compare April 26, 2022 11:08
brandonwillard
brandonwillard previously approved these changes Apr 27, 2022
README.rst Outdated
Comment on lines 42 to 43
next_step, _ = kernel(*initial_state, 1e-2)
print(next_step[0][1].eval({y_vv: 0}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our examples should probably use aesara.function and the returned updates (e.g. to avoid potentially confusing users down the line).

@brandonwillard brandonwillard force-pushed the return-internal-updates branch from b0104d9 to 56ee318 Compare April 27, 2022 23:33
@brandonwillard brandonwillard changed the title Make the HMC & NUTS kernel return scan updates Make the HMC & NUTS kernels return scan updates Apr 27, 2022
@brandonwillard brandonwillard merged commit 6c1836e into aesara-devs:main Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants