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

on_chip param lost when made in subnetwork #293

Open
studywolf opened this issue Jun 17, 2020 · 4 comments
Open

on_chip param lost when made in subnetwork #293

studywolf opened this issue Jun 17, 2020 · 4 comments

Comments

@studywolf
Copy link
Collaborator

I found this unexpected

import nengo
import nengo_loihi

def make_subnet():

    with nengo.Network() as subnet:
        nengo_loihi.add_params(subnet)
        subnet.ens = nengo.Ensemble(100, 1)
        subnet.config[subnet.ens].on_chip=False
    return subnet

with nengo.Network() as net:
    nengo_loihi.add_params(net)

    subnet = make_subnet()
    print(net.config[subnet.ens].on_chip)

prints out None

@drasmuss
Copy link
Member

drasmuss commented Jun 17, 2020

I think if you do print(subnet.config[subnet.ens].on_chip) it will work as expected (because that's where you set it, not net.config).

@hunse
Copy link
Collaborator

hunse commented Jun 17, 2020

What's more important is that setting on_chip on the subnet does not appear to work.

with nengo_loihi.Simulator(net) as sim:
    def print_ensembles(name, model):
        if len(model.params) == 0:
            return

        n_ensembles = len(set(obj for obj in model.params if isinstance(obj, nengo.Ensemble)))
        print("%s: %d ensembles" % (name, n_ensembles))

    print_ensembles("host_pre", sim.model.host_pre)
    print_ensembles("host", sim.model.host)
    print_ensembles("loihi", sim.model)

results in

loihi: 2 ensembles

for Travis's code above.

If I add net.config[subnet.ens].on_chip = False to Travis's code then I get the expected

host: 1 ensembles
loihi: 1 ensembles

@drasmuss
Copy link
Member

Ah yeah, related to nengo/nengo#1601, basically NengoLoihi only looks at the top-level config, it doesn't check nested configs at all I don't think.

@hunse
Copy link
Collaborator

hunse commented Jun 17, 2020

Yeah, related to that, though it's even a bit trickier because the splitting is pre-builder, so even though we're setting/unsetting model.config and thus have access to the current network config when building the ensemble, we don't have this when we're splitting.

Here's a sketch of a fix, https://github.com/nengo/nengo-loihi/tree/config-on-chip

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

No branches or pull requests

3 participants