Parameter sweep with distributed parallel network

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Parameter sweep with distributed parallel network

Post by pascal »

I have written some fairly complex distributed network code in which different groups of cells are hosted on different processors (i.e. NOT bulletin board style parallelization). My current simulations are not large enough to require parallel code (I currently run them with just one processor), but I wrote it in parallel anyway so I can scale up in the future.

I would like to take my current code and run a parameter sweep, stepping up the current injected into all cells with each new simulation. I tried to use a simple for loop like so

Code: Select all

pc=h.ParallelContext()

for istim in istim_vals:
    [[parallel simulation code with all cells receiving istim]]

pc.done()
but when I do this I get the error: gid=0 already exists on this process as an output port , which is associated with the method pc.set_gid2node.

So I figured I just needed to get a new ParallelContext object for each new simulation run. I tried:

Code: Select all

for istim in istim_vals:
    pc=h.ParallelContext()
    [[parallel simulation code with all cells receiving istim]]
    del pc
but this gives the same error as before.

Looking through the documentation, I see that I can use subworlds if I want to combine bulletin board parallelization with distributed parallelization, but I don't even need to get that complicated. I just want to run my distributed parallel code several times within a for loop. What is the simplest way to do this? Thanks for the help.
pascal
Posts: 106
Joined: Thu Apr 26, 2012 11:51 am

Re: Parameter sweep with distributed parallel network

Post by pascal »

Okay, this post
viewtopic.php?f=2&t=3213&p=13373&hilit=subworlds#p13373
helped me figure out the solution: I need to include a destructor in my "Net" class definition. I just added

Code: Select all

 
def __del__(self):
    pc.gid_clear()
to my Net class (which contains everything needed to run a simulation), then in my simulation code I used

Code: Select all

pc=h.ParallelContext()

for istim in istim_vals:
    [[parallel simulation of 'net' object (of the Net class) with all cells receiving istim]]
    del net

pc.done()
This simple addition resulted in my distributed parallel code being able to be run over and over again in a parameter sweep, just as I wanted.

But this leads to another question: in the above URL, Michael Hines states: "I would suggest a general tear down order is gid, netcon, cells." In my above destructor, I only tear down the gid's. How do I "tear down" the netcons and cells?
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Parameter sweep with distributed parallel network

Post by ted »

I don't see why you need a destructor at all, or how the thread you cite is relevant to what you are trying to do. If a network model has been implemented correctly, then repeated simulations with identical parameters should produce identical results, without having to be torn down and reconstructed. And the results should be the same regardless of whether execution is serial or parallel, or how many processors are used for parallel execution. If your code passes this test, you should be able to explore parameter space simply by iterating over all desired parameter combinations, one at a time e.g.

Code: Select all

repeat
  generate a new parameter set
  run a new simulation
until done
without having to throw away and rebuild your model before each new run.

"Oh, but my model includes synaptic plasticity, stochastic transmitter release that is governed by pseudorandom number streams, and noise that is emulated by using vector play to force the time course of IClamps."

Easily accommodated. Develop a custom initialization procedure that restores all of these to their proper starting points, and use an FInitializeHandler to ensure that this procedure is called at the beginning of every simulation.

Absolute reproducibility is not merely essential for debugging--code that fails this test cannot be verified. How is it possible to know if it is working properly?
Post Reply