SpiNNakerManchester / sPyNNaker

The SpiNNaker implementation of the PyNN neural networking language
Apache License 2.0
100 stars 42 forks source link

Faking/Hacking square wave current injection on SpiNNaker hardware. #415

Closed russelljjarvis closed 6 years ago

russelljjarvis commented 6 years ago

This might be a stupid conceptual idea, however, I wonder if it is possible to create a mechanism (perhaps synaptic on SpiNNaker that acts a bit like somatic current injection from an electrode. I was thinking that if it's not possible that may be because analogue neuronal input actually has a direct mapping to a hardware counterpart, and that hardware might not be able to be configured in a way that achieves near instantaneous changes to synaptic current?

The use case would be for a parallel optimization via neuronunit unit testing of neuronal models.

rowleya commented 6 years ago

In the current release of the tools, you can create square wave input by controlling the i_offset parameter of the neuron between calls to run e.g.:

import pyNN.spiNNaker as p

p.setup(1.0)
pop = p.Population(10, p.IF_curr_exp(i_offset=0))
pop.record("spikes")

p.run(100)

pop.set(i_offset=1.0)

p.run(100)

pop.set(i_offset=0.0)

p.run(100)

spikes = p.get_data("spikes")

p.end()

Does this do what you want or was there something else you needed?

russelljjarvis commented 6 years ago

Hi Andrew, This is probably what I want. I will try it out and see how it goes. Thanks. Russell.

russelljjarvis commented 6 years ago

Entering in the above code verbatim errors as is given below:

import pyNN.spiNNaker as p

p.setup(1.0)
pop = p.Population(10, p.IF_curr_exp(i_offset=0))
pop.record("spikes")

p.run(100)

pop.set(i_offset=1.0)

p.run(100)

pop.set(i_offset=0.0)

p.run(100)

spikes = p.get_data("spikes")

p.end()
HBP Neuromorphic Computing Platform: Job 92966 error

https://collab.humanbrainproject.eu/#/collab/5458/nav/42547?state=job.92966

2017-11-01 03:18:05 INFO: Read config files: /opt/git/SpiNNFrontEndCommon/spinn_front_end_common/interface/spinnaker.cfg, /opt/git/sPyNNaker/spynnaker/pyNN/spynnaker.cfg, /home/spinnaker/.spynnaker.cfg, ./spynnaker.cfg
2017-11-01 03:18:05 INFO: Will search these locations for binaries: /opt/git/SpiNNFrontEndCommon/spinn_front_end_common/common_model_binaries : /opt/git/sPyNNaker/spynnaker/pyNN/model_binaries
2017-11-01 03:18:05 INFO: Setting time scale factor to 1.
2017-11-01 03:18:05 INFO: Setting machine time step to 1000.0 micro-seconds.
2017-11-01 03:18:05 INFO: Simulating for 1 1000.000000ms timesteps using a hardware timestep of 1000000us
2017-11-01 03:18:05 INFO: Starting execution process
2017-11-01 03:18:06 INFO: Starting new HTTP connection (1): jabez.cs.man.ac.uk
2017-11-01 03:18:06 INFO: Time 0:00:00.041377 taken by HBPMaxMachineGenerator
2017-11-01 03:18:06 INFO: Time 0:00:00.016926 taken by VirtualMachineGenerator
Allocating virtual identifiers

.  .  .

==================
Error:
java.lang.Exception: Python exited with a non-zero code (1)
        at uk.ac.manchester.cs.spinnaker.jobprocess.PyNNJobProcess.execute(PyNNJobProcess.java:158)
        at uk.ac.manchester.cs.spinnaker.jobprocess.PyNNJobProcess.execute(PyNNJobProcess.java:49)
        at uk.ac.manchester.cs.spinnaker.jobprocessmanager.JobProcessManager.runJob(JobProcessManager.java:155)
        at uk.ac.manchester.cs.spinnaker.jobprocessmanager.JobProcessManager.main(JobProcessManager.java:235)

I fleshed out the example somewhat:

import pyNN.spiNNaker as sim
import numpy as np
import matplotlib.pyplot as plt
sim.setup(timestep=1.0, min_delay=1.0)
pop = sim.Population(100, sim.Izhikevich(i_offset=0))
pop.record("spikes")
sim.run(100)# delay 100ms
pop.set(i_offset=1.0)
sim.run(500)# duration 500
pop.set(i_offset=0.0)
sim.run(1000)# simulation length
spike_counts = pop.get_spike_counts()

Modifying the code again, in order to use the Izhikevich cell type rather than an Integrate and Fire cell causes the same error:

HBP Neuromorphic Computing Platform: Job 92964 error

https://collab.humanbrainproject.eu/#/collab/5458/nav/42547?state=job.92964

2017-10-31 23:29:16 INFO: Read config files: /opt/git/SpiNNFrontEndCommon/spinn_front_end_common/interface/spinnaker.cfg, /opt/git/sPyNNaker/spynnaker/pyNN/spynnaker.cfg, /home/spinnaker/.spynnaker.cfg, ./spynnaker.cfg
2017-10-31 23:29:16 INFO: Will search these locations for binaries: /opt/git/SpiNNFrontEndCommon/spinn_front_end_common/common_model_binaries : /opt/git/sPyNNaker/spynnaker/pyNN/model_binaries
2017-10-31 23:29:16 INFO: Setting time scale factor to 1.
2017-10-31 23:29:16 INFO: Setting machine time step to 1000.0 micro-seconds.
2017-10-31 23:29:16 INFO: Simulating for 1 1000.000000ms timesteps using a hardware timestep of 1000000us
2017-10-31 23:29:16 INFO: Starting execution process
2017-10-31 23:29:17 INFO: Starting new HTTP connection (1): jabez.cs.man.ac.uk
2017-10-31 23:29:17 INFO: Time 0:00:00.040220 taken by HBPMaxMachineGenerator
2017-10-31 23:29:17 INFO: Time 0:00:00.016538 taken by VirtualMachineGenerator
Allocating virtual identifiers

.  .  .

==================
Error:
java.lang.Exception: Python exited with a non-zero code (1)
        at uk.ac.manchester.cs.spinnaker.jobprocess.PyNNJobProcess.execute(PyNNJobProcess.java:158)
        at uk.ac.manchester.cs.spinnaker.jobprocess.PyNNJobProcess.execute(PyNNJobProcess.java:49)
        at uk.ac.manchester.cs.spinnaker.jobprocessmanager.JobProcessManager.runJob(JobProcessManager.java:155)
        at uk.ac.manchester.cs.spinnaker.jobprocessmanager.JobProcessManager.main(JobProcessManager.java:235)
alan-stokes commented 6 years ago

hi russel, get_spike_counts() is not yet impled in pynn 0.8 for spinnaker. I refer you to the following pull request: https://github.com/SpiNNakerManchester/sPyNNaker8/pull/74#issuecomment-340748941

therefore that snippit of code will fail due to not implemented error. For the time being, you could get spikes and count them yourself, its basically what the functionality will do under the hood once we've done it.

regards Alan

andrewgait commented 6 years ago

Also another problem I noticed in your first snippet of code, get_data(...) is a population function, so you need to change spikes = p.get_data("spikes") to spikes = pop.get_data("spikes") ; then, as Alan says, get_spike_counts() is not yet implemented on the released software version on the collab, so you would have to work out a way of counting the spikes yourself.

alan-stokes commented 6 years ago

having finally got around to having a working software stack (you should see the cod changes I'm making right now). I was able to run your code. it is indeed the get_spike_count that eventually fails. below is the stack trace error message that's on importance.

Traceback (most recent call last): File "/media/alan/DATA/spinnaker_software/PyNN8Examples/examples/test.py", line 12, in spike_counts = pop.get_spike_counts() AttributeError: 'Population' object has no attribute 'get_spike_counts'

alan-stokes commented 6 years ago

if you move to master of github, this issue is fixed. If using the collab......... ask @apdavison about supporting different release versions of the platforms support software. Otherwise I think you'll be waiting till our next release cycle.

regards Alan

alan-stokes commented 6 years ago

closing issue as solved in master tool chain. please reopen if another conclusion is reached

apdavison commented 6 years ago

ask @apdavison about supporting different release versions of the platforms support software

This is more an issue for @rowleya. The NMPI job has a JSON "hardware_config" field, which could include a "pyNN_version" or "system_version" entry, but then the SpiNNaker system needs to take account of this.

rowleya commented 6 years ago

I have a branch that does this but is untested ... hopefully I'll get around to trying it soon!