Using bionet iclamp with MPI fails due to accessing cells not on rank

Open
#331 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

Start in bmtk/simulator/bionet/modules/iclamp.py at initialize(), then inspect bmtk/simulator/bionet/bionetwork.py and get_cell_gid(). Reproduce the failure with the multi-rank current-clamp setup and verify that initialization accesses only cells local to each rank without raising the reported KeyError.

Written by the indexing model from the issue text.

Description

When adding a current clamp to cells on multiple ranks an error occurs when the gid isn't local to that rank -

Traceback (most recent call last):
  File "generate_traces.py", line 17, in <module>
    generate_parametric_traces(config)
  File "/home/tbg28/git_stage/act/act/utils.py", line 238, in generate_parametric_traces
    sim.run()
  File "/home/tbg28/git_stage/bmtk/bmtk/simulator/bionet/biosimulator.py", line 262, in run
    mod.initialize(self)
  File "/home/tbg28/git_stage/bmtk/bmtk/simulator/bionet/modules/iclamp.py", line 136, in initialize
    cell = sim.net.get_cell_gid(gid)
  File "/home/tbg28/git_stage/bmtk/bmtk/simulator/bionet/bionetwork.py", line 124, in get_cell_gid
    return self._rank_node_gids[gid]
KeyError: 0

A solution that worked for me was to update iclamp.py

# line 130
def initialize(self, sim):
        # Get select node gids, but only for those nodes that are on the current rank (if running on multiple cores)
        select_gids = list(sim.net.get_node_set(self._node_set).gids())
+        local_gids = sim.net.get_local_cells()
+        gids_on_rank = list(set(select_gids) & set(local_gids))
-         gids_on_rank = list(set(select_gids) & set(select_gids))

Will put up a PR for consideration.

Dominant language
Python
Stars
339
Forks
103
Avg merge
2h 7m
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AllenInstitute/bmtk

All issues in AllenInstitute/bmtk

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.