Skip to content
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

Passthrough removal broken when connecting from passthrough -> host #213

Open
arvoelke opened this issue Apr 1, 2019 · 1 comment
Open
Labels

Comments

@arvoelke
Copy link
Contributor

arvoelke commented Apr 1, 2019

import nengo
import nengo_loihi
from nengo_loihi.passthrough import convert_passthroughs

with nengo.Network() as model:

    u = nengo.Node(output=1)
    x = nengo.Ensemble(10, 1, label="x")
    passthrough = nengo.Node(size_in=1, label="passthrough")
    y = nengo.Ensemble(10, 1, label="y")
    offchip = nengo.Node(size_in=1, label="offchip")

    nengo.Connection(u, x)
    nengo.Connection(x, passthrough)
    nengo.Connection(passthrough, y)
    nengo.Connection(passthrough, offchip)

    p = nengo.Probe(offchip)

print(convert_passthroughs(model, {u}))

for remove_passthrough in (False, True):
    with nengo_loihi.Simulator(model,
                               remove_passthrough=remove_passthrough) as sim:
        sim.run(1.0)

    print("remove_passthrough=%s, offchip mean=%s" % (
        remove_passthrough, sim.data[p].mean()))
({<Node "passthrough" at 0x7ff72804d7f0>}, {<Connection at 0x7ff7282c3ba8 from <Node "passthrough"> to <Node "offchip">>, <Connection at 0x7ff7284166a0 from <Node "passthrough"> to <Ensemble "y">>, <Connection at 0x7ff73116fef0 from <Ensemble "x"> to <Node "passthrough">>}, {<Connection at 0x7ff7282c3cf8 from <Ensemble "x"> to <Ensemble "y">>})
remove_passthrough=False, offchip mean=0.8331233504684199
remove_passthrough=True, offchip mean=0.0

The passthrough is removed, and no connections are made to replace nengo.Connection(passthrough, offchip). As a result, the offchip probe reports a flat zero, unless of course remove_passthrough is disabled.

@arvoelke arvoelke added the bug label Apr 1, 2019
arvoelke added a commit that referenced this issue Apr 1, 2019
Outstanding issues for True include: #210, #212, #213
hunse pushed a commit that referenced this issue Apr 3, 2019
Most of the work done by the splitter is now done in the builder.
This should give more clarity and control over the mapping between
pre-build and post-build objects. The `SplitterDirective` class
takes on the organizational tasks of the old `Splitter`, giving
directives to the builder about what should be on- or off-chip.

Also:
- Add unit tests for splitter refactoring.
- Raise `BuildError` if learning objects are on_chip. Fixes #208
  and #209.
- Pass no decoder cache to sub-models. Decoder cache wasn't working
  due to lack of context manager which is normally constructed by
  the top-level network build. Fixes #207.
- Various improvements to passthrough removal, including not removing
  useful passthrough nodes.
  Outstanding issues include: #210, #212, #213
- Handle sliced probes. Closes #205.
- Check that splitter handles sliced probes. Closes #206.
- Test that splitter does not mutate network. Closes #211.
hunse pushed a commit that referenced this issue Apr 3, 2019
Most of the work done by the splitter is now done in the builder.
This should give more clarity and control over the mapping between
pre-build and post-build objects. The `SplitterDirective` class
takes on the organizational tasks of the old `Splitter`, giving
directives to the builder about what should be on- or off-chip.

Also:
- Add unit tests for splitter refactoring.
- Raise `BuildError` if learning objects are on_chip. Fixes #208
  and #209.
- Pass no decoder cache to sub-models. Decoder cache wasn't working
  due to lack of context manager which is normally constructed by
  the top-level network build. Fixes #207.
- Various improvements to passthrough removal, including not removing
  useful passthrough nodes.
  Outstanding issues include: #210, #212, #213
- Handle sliced probes. Closes #205.
- Check that splitter handles sliced probes. Closes #206.
- Test that splitter does not mutate network. Closes #211.
@tcstewar
Copy link
Collaborator

tcstewar commented May 6, 2021

Here's another network that triggers this bug (or a very related one):

model = nengo.Network()
with model:
    stim = nengo.Node(np.sin)
    s1 = nengo.Node(None, size_in=1)
    out = nengo.Node(None, size_in=1)
    nengo.Connection(stim, s1, synapse=None)
    nengo.Connection(s1, out)
    
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(s1, a)
    nengo.Connection(a, out)
    
    p = nengo.Probe(out)

I'm probing out, and it has two inputs: one from the on-chip Ensemble a, and one from s1 which is just an off-chip passthrough Node whose only input is the stimulus Node stim. The result is a probe that just records 0 all the time (rather than recording the sum of a and stim). If you change either of the Nodes from passthroughs to lambda t,x:x Nodes, then the problem goes away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants