Access to STDP rules supported by Loihi

Hello,
I am new to Nengo and Loihi and I have just been able to run the various examples in the Nengo Loihi documentation. I am wondering if it is possible to use the STDP rules supported by Loihi in a Nengo model, or whether there are plans to implement them and what is needed for that to happen. Thanks for any help.

Hello iraikov,

No, currently only the PES learning rule is supported in Nengo Loihi. You can use lots of learning rules in Nengo core (including STDP), but they wouldn’t be running on the Loihi chip. We would like to add more learning rules to Nengo Loihi, but it’s a significant amount of work so it probably won’t be supported in the near term.

Hi, I hope it’s fine to revive the topic! I was wondering if there are any plans to add STDP (or OJA/BCM) for Nengo Loihi at some point?

If not, is there by any chance some convenient way to interface the Nengo Loihi API with the general Loihi Python API? I guess it should theoretically be possible to take the (full) weight matrices calculated by Nengo and use them in a standard Loihi model.

Hi Matthijs,

Unfortunately, there are no plans to add any more learning rules to NengoLoihi at this point.

If you’re happy to do the learning off-chip, then the easiest solution is probably to do the learning in Nengo (without Loihi) and then take the calculated weight matrices and use them in NengoLoihi, as you suggest. Let us know if you want help getting something like that working.

If you want to do the learning on-chip, you can access the Loihi Python API (i.e. NxSDK) through NengoLoihi. Here’s a sketch of how you might do that:

with nengo.Network() as network:
    nengo_loihi.set_defaults()

    pre_ens = nengo.Ensemble(100, 1)
    post_ens = nengo.Ensemble(100, 1)
    initial_transform = np.random.uniform(-0.01, 0.01, size=(100, 100))
    nengo.Connection(pre_ens.neurons, post_ens.neurons, transform=initial_transform)

sim = nengo_loihi.Simulator(network, target="loihi")

# get the `HardwareInterface` (see `nengo_loihi/hardware/interface.py`)
hw_interface = sim.sims["loihi"]

# find the chip/core corresponding to `post_ens`
blocks = sim.model.objs[post_ens]["out"]
blocks = blocks if isinstance(blocks, (list, tuple)) else [blocks]

assert len(blocks) == 1, "For this basic example, we'll just worry about small ensembles"
block = blocks[0]
chip_idx, core_idx, _, _, _ = hw_interface.board.find_block(block)

# get the `N2Board` object (see NxSDK documentation)
n2board = hw_interface.nxsdk_board

# get the NxSDK object for the core that `post_ens` is on
n2core = n2board.n2Chips[chip_idx].n2CoresAsList[core_idx]

# Do custom stuff here, doing what's needed to add learning to the synapses

# run the simulation
with sim:
    sim.run(runtime_in_seconds)

Note that this will only work if your nengo_loihi.Simulator is connecting to an actual Loihi; there’s no way to prototype this without access to a Loihi.

2 Likes

Hi Eric,
thank you very much, the second option of accessing the Loihi Python API through Nengo Loihi would be exactly what we need!