Inheritance diagram of lava.magma.core.sync.protocols.async_protocol
class lava.magma.core.sync.protocols.async_protocol.AsyncProtocol

Bases: AbstractSyncProtocol

Protocol to run processes asynchronously.

With the AsyncProtocol, Processes are executed without synchronization on specific phases. This means that the Processes could run with a varying speed and message passing is possible at any time.

AsyncProtocol is currently only implemented for execution on CPU using the PyAsyncProcessModel in which the run_async() function must be implemented to define the behavior of the underlying Process.

For example:

>>>    @implements(proc=SimpleProcess, protocol=AsyncProtocol)
>>>    @requires(CPU)
>>>    class SimpleProcessModel(PyAsyncProcessModel):
>>>        u = LavaPyType(int, int)
>>>        v = LavaPyType(int, int)
>>>        def run_async(self):
>>>            while True:
>>>                self.u = self.u + 10
>>>                self.v = self.v + 1000
>>>                if self.check_for_stop_cmd():
>>>                    return
phases = []
proc_functions = []
property runtime_service


Inheritance diagram of lava.magma.core.sync.protocols.loihi_protocol
class lava.magma.core.sync.protocols.loihi_protocol.LoihiProtocol

Bases: AbstractSyncProtocol

A ProcessModel implementing this synchronization protocol adheres to the phases of execution of the neuromorphic processor Loihi.

Each phase is implemented by a dedicated method. Loihi’s phases of execution are listed below in order of execution. A ProcessModel adhering to this protocol must implement each phase in a dedicated method. Additionally, for each phase (except the spiking phase), a “guard” method must be implemented that determines whether its respective phase is executed in the given time step.

For example: To execute the post management phase (‘run_post_mgmt()’), the function post_guard() must return True.

>>> def post_guard(self) -> bool:
>>>     return True
>>> def run_post_mgmt(self) -> None:
>>>     # i.e. read out a variable from a neurocore

Phases The phases are executed in this order:

  1. Spiking phase:

    Synaptic input is served, neuron states are updated and output spikes are generated and delivered. This method is always executed and does not have a corresponding guard method.


    ‘run_spk()’ -> None



  2. Pre management phase (run_pre_mgmt):

    Memory is consolidated before the learning phase. In order to jump into this phase, ‘pre_guard’ and learn_guard must return True.


    ‘run_pre_mgmt()’ -> None


    learn_guard() -> None, and pre_guard() -> None

  3. Learning phase:

    Activity traces are calculated, learning rules are applied and parameters (weights, thresholds, delays, tags, etc) are updated. In order to jump into this phase, ‘lrn_guard’ must return True.


    ‘run_lrn()’ -> None


    learn_guard() -> None

  4. Post management phase:

    Memory is consolidated after learning phase. Read and write access to neuron states are safe now. In order to jump into this phase ‘post_guard’ must return True.


    ‘run_post_mgmt()’ -> None


    learn_guard() -> None

  5. Host phase:

    Memory of the host system is consolidated. In order to jump into this phase ‘host_guard’ must return True.


    ‘run_host_mgmt()’ -> None


    host_guard() -> None

phases = [array([1.]), array([2.]), array([3.]), array([4.]), array([5.])]
proc_functions = [Proc_Function_With_Guard(guard='pre_guard', func='run_pre_mgmt'), Proc_Function_With_Guard(guard='lrn_guard', func='run_lrn'), Proc_Function_With_Guard(guard='post_guard', func='run_post_mgmt'), Proc_Function_With_Guard(guard='host_guard', func='run_host_mgmt'), Proc_Function_With_Guard(guard=None, func='run_spk')]
property runtime_service

Return RuntimeService.

class lava.magma.core.sync.protocols.loihi_protocol.Phase

Bases: object

HOST = array([5.])
LRN = array([3.])
POST_MGMT = array([4.])
PRE_MGMT = array([2.])
SPK = array([1.])
class lava.magma.core.sync.protocols.loihi_protocol.Proc_Function_With_Guard(guard, func)

Bases: tuple


Alias for field number 1


Alias for field number 0