-
Notifications
You must be signed in to change notification settings - Fork 19
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 indexing for chains in different threads #154
Conversation
23ba9c0
to
d194f86
Compare
d194f86
to
ec621b7
Compare
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.
I'm happy with the code, just wondering about whether this could be tested somehow. End-to-end is hard, but might it make sense to put the chainidxs
logic in a function that could be tested with given values for nchains
and number of threads?
Co-authored-by: David Widmann <[email protected]>
@mhauru the logic itself feels too basic to be worth testing to me 😅. I checked again locally with the most recent commit and it still behaves correctly, so it has been end-to-end tested, albeit not in CI. |
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.
I get paranoid about off-by-one mistakes with all index arithmetic, and testing can also guard against botched future changes. If the person who wrote the previous version would have added tests we wouldn't be here. But I do see that this is very minimal, and also it's not introducing untested functionality, it's rather fixing untested functionality, so I'm okay with merging as-is. Thanks for fixing!
Closes #153
If there were 6 threads and 9 chains, the previous code (
AbstractMCMC.jl/src/sample.jl
Lines 441 to 445 in 5a3b155
chainidxs
for each threadSomewhere later on (probably in the fifth thread with
chainidxs = 9:10
) this causes indexing errors as we only have a vector of size 9.This PR changes it such that for the same inputs (6 threads and 9 chains) it generates the following
chainidxs
The error in #153 is fixed