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
[MRG] fix inconsistent random state assignment between parallel trials #171
[MRG] fix inconsistent random state assignment between parallel trials #171
Conversation
hnn_core/parallel_backends.py
Outdated
|
||
neuron_net = NetworkBuilder(net) | ||
neuron_net.net.trial_idx = trial_idx |
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.
is this equivalent to https://github.com/jonescompneurolab/hnn-core/pull/171/files#diff-ca5f146e027d9dc6ef29ff4db9c21ca2R68 ? I have a suspicion it is not. Can you check?
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.
You're right, I messed this up. Fixed in b340fe0.
@@ -353,6 +352,11 @@ def _create_cells_and_feeds(self): | |||
External inputs are not targets. | |||
""" | |||
params = self.net.params | |||
# Re-create external feed param dictionaries |
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.
should we add an "XXX" in the comment somewhere? To indicate that this is a hack (right?) and we should get rid of at some point
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.
Hmm, I'm not sure in this scenario what delineates a hack from a long-term bug fix. We plan to refactor the params and feed modules wrt how feed objects and their respective parameters are passed to Network
and NetworkBuilder
. Along the way we will end up simplifying the code by e.g. removing the need for calling create_pext()
here. That said, I'm happy to update the comment if you think it'd be clearer.
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.
yeah, I agree it might go away but just leaving an XXX tells future contributors that it's a hack that needs to fixed.
I have a hunch that digging into this might solve your issue. Then ideally, we can add a tiny test to check that MPI vs Joblibs gives same result for 2 trials (with a 3 x 3 network to make it run fast). If it doesn't work, I am fine merging the PR as is if it's good by @blakecaldwell do make sure to update |
Codecov Report
@@ Coverage Diff @@
## master #171 +/- ##
==========================================
+ Coverage 67.61% 68.50% +0.88%
==========================================
Files 19 19
Lines 1930 1959 +29
==========================================
+ Hits 1305 1342 +37
+ Misses 625 617 -8
Continue to review full report at Codecov.
|
Update with b340fe0: the script that generated the plots shown at the beginning of this PR now produces the same results for the joblib and mpi backends when running the default param set: |
Amazing! do you think we could add a tiny test?
you can use a small network, e.g., also don't forget to update |
I've updated |
Fantastic, thanks for making the changes. PR looks good to me, merged! |
fixes #136
Running the code here creates this plot with
MPI_Backend
:and this plot for
JoblibBackend
:Note that while individual trials are not exactly the same between the two versions (most likely due to an inconsistency in the trajectories of random states), both show 10 distinct trials that emerged from distinct random states. If anyone can readily spot where the discrepancy is occurring it be much appreciated. Otherwise we might want to address that in another PR since the tests are still passing.
This PR also addresses some of the inconsistent messaging that gets output during a simulation in the terminal.