Skip to content

Projection.get(..., format='array') raises IndexError on non-root MPI ranks when a single attribute is requested (default gather=True) #847

Description

@apdavison

First reported in #573, which proposes changing the default to gather='all' as a workaround. Opening this as a standalone issue to track the underlying bug.

Summary

Under MPI, Projection.get(name, format='array') with a single attribute name and the default gather=True raises IndexError on any non-root rank that holds no local connections for the projection. (Requesting multiple attributes doesn't crash on this path — it returns a wrongly-typed local list instead, via the return values branch.)

The default gather=True only fully populates the result on rank 0; other ranks fall through to return values[0] where values is their raw local connection list, which may be empty.

Reproducer

# mpirun -np 2 python repro.py
import pyNN.nest as sim

sim.setup()
p1 = sim.Population(4, sim.IF_cond_exp())
p2 = sim.Population(4, sim.IF_cond_exp())
prj = sim.Projection(p1, p2, sim.OneToOneConnector(), sim.StaticSynapse(weight=0.1))

# default gather=True, array format, single attribute
weights = prj.get("weight", format="array")   # IndexError on a rank with no local connections
sim.end()

Runs fine in serial; under mpirun -np 2 a non-root rank with no local connections raises:

File ".../pyNN/common/projections.py", line 397, in get
    return values[0]
IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions