-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Possible issue with new RNG? #3285
Comments
Oh hold on - it looks like the issue is the
|
That sounds really dangerous---@mitzimorris and @SteveBronder should know if this is going to be an issue through Stan or CmdStan---we need to check somewhere that seeds aren't zero. |
I think that a seed of zero was working fine in the past. |
Yep, but it will be a problem with the new RNG in Stan ( |
Should we change it to check for zero as the seed and if it is just +1? |
No, because then a user supplying 0 and a user supplying 1 get the same answer. It'd be better to add 1 to all the inputs, which just means whatever the max is will have to be one less. |
I can't reproduce up at the cmdstan level - supplying seed 0 and id 0, I still get valid sampling behavior, no repeat draws @andrjohns do you observe the bad behavior up at the cmdstan level? If so this is possibly an architecture issue or boost bug? |
Note that this was actually already the case with the previous rng in Stan |
Looks like it's definitely a Boost bug - reproduced on godbolt. I'll file an issue with Boost now EDIT: upstream issue here: boostorg/random#104 |
The papers on the mixmax generator say the seed needs at least 1 nonzero bit. We have a bunch of extra bits to work with in the end, so we can definitely ensure that |
Separate from the discussion on what's the best way to turn the user-supplied seed into an initialization for the pRNG, do we have an explanation for why this bug seems to not matter at the integration-test level? E.g., why can I still get good samples from my model if I specify seed=0 id=0 at the moment. |
You can see it with the unconstrained initial values. If you update the random_var_context to print the inits after generation: for (size_t n = 0; n < num_unconstrained_; ++n) {
unconstrained_params_[n] = unif(rng);
std::cout << "unconstrained_params_[" << n << "] = "
<< unconstrained_params_[n] << std::endl;
} And update the bernoulli example to have multiple parameters ( You can see in the output:
|
Let me rephrase: at what point does the randomness "start working" such that I end up with what look like valid samples from the posterior with the bad seed? Presumably if the momentum refresh in HMC is also getting turned into a deterministic value, we wouldn't be getting correct sampling behavior (unless the Bernoulli example is so simple it "works" anyway?) |
Even if momentum resampling is deterministic, the MCMC trajectory is going to be quite complicated and (I imagine) might well look pseudorandom. Maybe you need more effective samples, or the problems are only visible in higher moments (variance, skewness, etc) |
I was running a version of Bernoulli which was also doing a posterior predictive check to generate new Ys, which also looked fine, but presumably that’s because the parameters of the rng were different each iteration |
Description:
Not sure if this is a bug or just me doing things wrong, but it looks like the new RNG doesn't interact with the Math library in the same way - the return is always constant:
Gives:
Current Version:
v2.35.0
The text was updated successfully, but these errors were encountered: