nengo / nengo-loihi

Run Nengo models on Intel's Loihi chip
https://www.nengo.ai/nengo-loihi/
Other
35 stars 12 forks source link

Passthrough removal is too aggressive #212

Open arvoelke opened 5 years ago

arvoelke commented 5 years ago

Passthrough nodes should only be removed if they are connecting chip -> chip (according to the convert_passthroughs docstring), that is, any nodes between x and y (not shown).

However, it will remove passthrough nodes that are on host that never connect back to the chip. For example, if those nodes are not probed.

import nengo
import nengo_loihi
from nengo_loihi.passthrough import is_passthrough

import logging
logging.basicConfig(level=logging.INFO)

for remove_passthrough in (True, False):
    with nengo.Network() as model:

        x = nengo.Ensemble(10, 1, label="x")
        y = nengo.Ensemble(10, 1, label="y")
        a = nengo.Node(size_in=1, label="a")
        b = nengo.Node(size_in=1, label="b")
        assert is_passthrough(a)
        assert is_passthrough(b)

        nengo.Connection(x, a)
        nengo.Connection(x, b)
        nengo.Probe(a)

    with nengo_loihi.Simulator(model, remove_passthrough=remove_passthrough) as sim:
        pass

    for obj in (a, b):
        print("remove_passthrough=%s, %s in params=%s" % (
            remove_passthrough, obj.label, obj in sim.sims["host"].model.params))
remove_passthrough=True, a in params=True
remove_passthrough=True, b in params=False
remove_passthrough=False, a in params=True
remove_passthrough=False, b in params=True

The ideal output should be:

remove_passthrough=True, a in params=True
remove_passthrough=True, b in params=True
remove_passthrough=False, a in params=True
remove_passthrough=False, b in params=True

because none of the nodes here are in between chip -> chip connections.

drasmuss commented 4 years ago

Result of internal discussion: While this would be nice to support, it's difficult because we don't know which parts of the model will be on or off chip until after the passthrough removal completes (since it can change which parts are on/off chip). We could work around that by reworking that whole build pipeline, but it also seems relatively low priority, since a) removing passthroughs on the host side should have relatively little impact, and b) the main use case for nengo-loihi is models where most or all of the model is running on-chip (so adding that feature wouldn't affect them).

So our plan for now is just to update the documentation to clarify that remove-passthroughs removes all passthroughs (on or off chip).