lava.magma.core.sync.protocols

lava.magma.core.sync.protocols.async_protocol

digraph inheritance81f23a5efb { bgcolor=transparent; rankdir=TB; size=""; "AbstractSyncProtocol" [URL="../lava.magma.core.sync.html#lava.magma.core.sync.protocol.AbstractSyncProtocol",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for `SyncProtocols`."]; "AsyncProtocol" [URL="../lava/lava.magma.core.sync.protocols.html#lava.magma.core.sync.protocols.async_protocol.AsyncProtocol",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Protocol to run processes asynchronously."]; "AbstractSyncProtocol" -> "AsyncProtocol" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
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

lava.magma.core.sync.protocols.loihi_protocol

digraph inheritancecdac66ba06 { bgcolor=transparent; rankdir=TB; size=""; "AbstractSyncProtocol" [URL="../lava.magma.core.sync.html#lava.magma.core.sync.protocol.AbstractSyncProtocol",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for `SyncProtocols`."]; "LoihiProtocol" [URL="../lava/lava.magma.core.sync.protocols.html#lava.magma.core.sync.protocols.loihi_protocol.LoihiProtocol",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A ProcessModel implementing this synchronization protocol adheres to the"]; "AbstractSyncProtocol" -> "LoihiProtocol" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NxSdkRuntimeService" [URL="../lava/lava.magma.core.sync.protocols.html#lava.magma.core.sync.protocols.loihi_protocol.NxSdkRuntimeService",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Phase" [URL="../lava/lava.magma.core.sync.protocols.html#lava.magma.core.sync.protocols.loihi_protocol.Phase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Proc_Function_With_Guard" [URL="../lava/lava.magma.core.sync.protocols.html#lava.magma.core.sync.protocols.loihi_protocol.Proc_Function_With_Guard",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Proc_Function_With_Guard(guard, func)"]; }
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.

    Method:

    ‘run_spk()’ -> None

    Guard:

    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.

    Method:

    ‘run_pre_mgmt()’ -> None

    Guard:

    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.

    Method:

    ‘run_lrn()’ -> None

    Guard:

    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.

    Method:

    ‘run_post_mgmt()’ -> None

    Guard:

    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.

    Method:

    ‘run_host_mgmt()’ -> None

    Guard:

    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.NxSdkRuntimeService

Bases: object

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

func

Alias for field number 1

guard

Alias for field number 0