-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Error regarding dimensions after sampling. #1050
Comments
Wow, that's very strange! I'm not able to reproduce this on either of my computers (although they're both Macs, just running different OS versions), which is going to make this tricky to debug. Does this happen with all models or just specific ones?
There's a decent chance that line in the posterior package is where the error is coming from, but, if so, I'm not sure why. Are you able to generate a |
Thanks for the fast reply! Here's the output of traceback. I have to admit I don't quite know how to interpret it.
|
Was able to put together a reproducible example in Docker here: https://gist.github.com/tillahoffmann/ada92a970706c772c6ad2a477ec95fb2 |
Thanks, that's great. I'll build the image now, but unfortunately the rest of the day and the next week is insanely busy for me so I'm not sure when I'm going to have the time to dig into this if it doesn't turn out to be really simple . I'll try to make some time though! I think the traceback confirms your suspicion that the error is happening in those lines from posterior, but I'm not sure why yet. |
Does this happen with all models or just certain ones? |
Sorry, forgot to address that earlier. I don't know if it happens for all models, but it seems to be an issue even for very simple ones like this one. parameters {
real f;
}
model {
f ~ normal(0, 1);
} The error messsage is as follows.
I've just played around with this a bit more, and it only seems to happen if a single chain is run. It works fine for multiple chains. Edit: It looks like the number 150 is not related to the size of the vector but the number of samples. Specifically, the reported number is |
Thanks for the extra details. This is indeed quite strange.
The error seems to be happening when processing the data frame of sampler diagnostics, which your docker image helped me figure out. The data frame has |
It's weird with the Docker image. Maybe it's related to being on Linux rather than macOS? R being differently on Linux and macOS would be surprising, but I'm no R expert. |
This keeps getting stranger. So the function in the posterior package that you found (https://github.com/stan-dev/posterior/blob/79d4521b943e44f4ac31636c4488d9e2cfeac3ec/R/as_draws_array.R#L227-L239) is indeed where the error is happening. On my computer the input to that function is a list of matrices (one per chain). In the Docker image the input to that function is a list of data frames (one per chain, if chains > 1) and a single data frame if chains = 1. |
@tillahoffmann @paul-buerkner I think the problem is this commit to posterior: stan-dev/posterior@79d4521. I finally noticed that it was using the very latest development version from posterior. When I first tested that I couldn't reproduce the error deterministically because I hadn't refreshed my R session when installing different versions of posterior (I thought I had but I hadn't). When I did that I could reproduce the error. |
Ok @tillahoffmann check out stan-dev/posterior#386. Can you replicate that? This should also mean that if you use the posterior package that’s on CRAN, not the latest GitHub version, the error should go away (I hope). |
Thank you for the thorough investigation. Yes, I can replicate the behavior from stan-dev/posterior#386. |
Ok great, thanks for checking and for reporting this. |
We reverted the problematic commit in posterior, so I'm going to close this |
Thanks again for reporting this and creating the reproducible example in Docker, that was really helpful. |
Great, thank you for digging into it and fixing it so quickly! I probably shouldn't be running single chains anyway. 😬 |
Describe the bug
After the model completes sampling, the following error is raised.
To Reproduce
Expected behavior
The R code above returns a fit.
Operating system
I am running this code in a Docker container with the above operating system.
I do not get an error if I run the same code on the host machine with the following configuration.
$ uname -a Darwin dhcp-10-250-31-164.harvard.edu 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:14 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8103 arm64 $ gcc --version Apple clang version 16.0.0 (clang-1600.0.26.6) Target: arm64-apple-darwin24.1.0
The output on the host machine is as follows.
CmdStanR version number (same in container and on host)
Additional context
This problem arose in running the reproduction materials for our Gaussian process inference library after upgrading
cmdstan
andcmdstanr
(cf. onnela-lab/gptools-reproduction-material#4).I searched GitHub for the code in the error message and found this section. Maybe it's relevant.
https://github.com/stan-dev/posterior/blob/79d4521b943e44f4ac31636c4488d9e2cfeac3ec/R/as_draws_array.R#L227-L239
The text was updated successfully, but these errors were encountered: