nengo / nengo-loihi

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

Output difference between `target='sim'` and `target='loihi'` #57

Open tcstewar opened 6 years ago

tcstewar commented 6 years ago

Here's the simplest model I've come up with where there's a difference between output from the actual chip and the output from the approximation of the chip that's built in to nengo_loihi.

def test_identical_outputs(Simulator):
    D = 1
    N = 100
    with nengo.Network(seed=1) as net:
        stim = nengo.Node([0]*D)
        a = nengo.Ensemble(n_neurons=N, dimensions=D)
        nengo.Connection(stim, a)
        b = nengo.Ensemble(n_neurons=N, dimensions=D)
        nengo.Connection(a, b)

        p = nengo.Probe(b)

    with Simulator(net, target='sim', precompute=False) as sim:
        sim.run(0.1)
    with Simulator(net, target='loihi', precompute=False) as loihi:
        loihi.run(0.1)

    print(sim.data[p][15:25,0])
    print(loihi.data[p][15:25,0])

    assert np.allclose(sim.data[p], loihi.data[p], atol=1e-6)

Here is the printed output, showing the point in time where the outputs diverge:

[ 0.          0.          0.00670498 -0.10392723 -0.35871656  0.13745214 -0.41570891  0.10392723  0.18438702  0.48948991]
[ 0.          0.          0.00670498 -0.10392723 -0.35871656 -0.06042342 -0.35536407  0.24137937  0.34200649  0.3319752 ]

Note that for both target='sim' and target='loihi', the setting of precompute does not affect the output for this test.

tbekolay commented 6 years ago

If anyone starts debugging this, please post the full details here.

hunse commented 6 years ago

I believe this is expected, since these connections have interneurons. Interneurons have noise in them, and we do not perfectly model the Loihi noise generation. If I add solver=nengo.solvers.LstsqL2(weights=True) to the connection from a to b, the outputs are identical.