-
Notifications
You must be signed in to change notification settings - Fork 246
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
fix(tests): update tolerance levels and PRNGKey
usage for improved test stability
#1959
Conversation
@Qazalbash thanks for taking a close look at this !!
can you please explain why it's not possible (or why it's difficult) to get rid of more "magic numbers" like |
While addressing a similar issue in a personal project, I found that the most practical solution was to modify the random seed. Since I am not an expert in probability or statistics, I assumed that the tolerances, as well as the relative and absolute error thresholds, are inherently tied to the algorithm's precision. To avoid altering these parameters, I opted to adjust the input data by changing the random keys.
Initially, I experimented with various integers, including prime numbers and other two-digit values. However, after some time, I decided to explore more meaningful options, such as historically significant dates or personal milestones, including my own birthday. Surprisingly, these choices proved effective in resolving the issue :). I can not argue 'to get rid of more "magic numbers"' you can explore if running tests on higher precision works! Because almost all the failing ones were passing on higher precision without a change of seed value. My suggestion would be, if you don't want to encounter more magic numbers, shifting to higher precision will be a better choice. |
I think we should avoid magic numbers and address the numerical issues directly. It is better to have tests which are rarely failing (rather than sometimes passing). |
I can take a stab at it. |
I second that! If you like I can test it. |
Sure, thanks!! |
PRNGKey
usage for improved test stability
…64` and `test_get_proposal_loc_and_scale`
Maybe the init values of the change_point test make MCMC stuck at local minimal. How about setting
|
There are a couple of failing tests:
Edit: turns out that you already did |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge thanks for fixing this annoying issue, @Qazalbash!
It is pretty suspicious these test cases were passing in 85d4982 even though py3.10 had |
Could you increase atol there? I feel the test is incorrect |
Some more test cases have failed! Can you check > assert_allclose(act_loss, exp_loss)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=0
E
E Mismatched elements: 1 / 1 (100%)
E Max absolute difference among violations: 14.192255
E Max relative difference among violations: 5.6824265
E ACTUAL: array(-16.689825, dtype=float32)
E DESIRED: array(-2.49757, dtype=float32)
test/contrib/einstein/test_stein_loss.py:95: AssertionError |
Sure. I dont think it is needed for other PRs |
With the release of
jax==0.5.0
, thejax_threefry_partitionable
mode is now enabled by default. This change has caused some test cases to fail because the random numbers generated with the same seed differ depending on the status ofjax_threefry_partitionable
. For example,Example
Tolerance levels are updated for failing test cases.