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 artificial cell gid assignment for non-cell-specific drives #399
Conversation
hnn_core/network_builder.py
Outdated
n_drive_cells = len(self._drive_cells) | ||
print(f'n_art_cells = {n_drive_cells}') |
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 temporarily including these lines to demo the issue. Previously, a simulation using MPIBackend
with 6 processes would end up creating at total of 80 drive cells when 20 were expected.
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.
can you think of a way to test the gid assignments? I think you might have to be a little clever how you set it up. E.g., have a parameter called rank
or test_mode
in one of the functions that fakes the MPIBackend
with rank > 1
. See how we do something similar in MNE:
or maybe have rank
as an attribute of NetworkBuilder
or Network
that is set once somewhere and you can manually tweak it or set it automatically from _get_rank
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.
That's a good idea. I'll give it a shot, though I probably won't be able to get around to it until later next week.
Codecov Report
@@ Coverage Diff @@
## master #399 +/- ##
==========================================
+ Coverage 90.13% 90.16% +0.03%
==========================================
Files 17 17
Lines 3050 3060 +10
==========================================
+ Hits 2749 2759 +10
Misses 301 301
Continue to review full report at Codecov.
|
I gave your suggestion a try in 02b6e60 @jasmainak, but am now encountering the following error:
Do you have any idea what's going on or know of a better way to structure this test? |
hnn_core/network_builder.py
Outdated
for gid in self._gid_list: | ||
_PC.set_gid2node(gid, rank) |
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.
@rythorpe see how I separated the Neuron code. Now you can test the code above without making a call to Neuron
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.
Ahh yes, now I see it. Thanks @jasmainak!
n_drive_cells_instantiated = dict() | ||
for rank in range(n_ranks): | ||
net_builder = NetworkBuilder(net) | ||
net_builder._build(test_rank=rank) |
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.
just test _gid_assign
, not the whole _build
... and separate out the Neuron calls because you don't really have rank > 0. You are trying to create a fake rank
't_evdist_1': 10, | ||
't_evprox_2': 20, | ||
'N_trials': 2}) | ||
net = jones_2009_model(params, add_drives_from_params=True) |
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.
net = jones_2009_model(params, add_drives_from_params=True) | |
net = jones_2009_model(params, add_drives_from_params=False) |
you might want to use _gid_list
for the test. Add a drive explicitly and check if it contains all the gids
in one rank if it's non-cell-specific etc.
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.
Done. See cce3bd9.
@@ -330,7 +330,7 @@ def _update_cells(self): | |||
cell.gid = self.gid_ranges[cell_type][cell_idx] | |||
cell.pos = pos | |||
cells.append(cell) | |||
self.cells[cell_type] = cells | |||
self.cells[cell_type] = cells |
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.
Subtle, assuming this is a silent fix where the final behavior is the same?
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.
Correct. When I was trying to find the root of the discrepany between the two parallel backends, I realized that we don't need to assign the list of cell objects to the net.cells
dict every time it iterates through the innermost loop. Just a super minor performance improvement.
Aside from the MPI test failing as in #406, I think this is ready to go. Any other suggestions @jasmainak and @ntolley? |
Is the MPI test failing consistently? I just restarted the CI so hopefully it passes. We can't merge PRs unless all tests pass ... |
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.
LGTM @ntolley do you want to merge once the CIs are green?
@rythorpe what's our plans with this example: https://1901-168215891-gh.circle-artifacts.com/0/html/auto_examples/howto/plot_simulate_mpi_backend.html#sphx-glr-auto-examples-howto-plot-simulate-mpi-backend-py ? Is that good as it is or do we want to use a seed to make it look more sinusoidal as it was before? |
@rythorpe appologies for the late test suggestion! Happy to merge after addressing the remaining questions |
How do you feel about this simulation with |
Happy to merge, but for some reason github actions wasn't triggered for the test suite? |
That's curious. Do you know how to force them to run? |
Go for it @ntolley! |
good stuff, happy how this PR shaped up! |
As noticed in #383, this resolves the discrepancy between
MPIBackend
andJoblibBackend
for simulations that include non-cell-specific drives (e.g., bursty/rhythmic drives).