localuf.decoders.luf.main¶
Classes for local Union–Find decoder.
Classes
|
Node for LUF w/o direct access to blind global controller. |
|
Collection of all LUF nodes, where controller only sees node whose ID is 0. |
|
Global controller for LUF. |
|
Friendship w/ controller. |
|
The type of connection for communicating |
|
The graph used by local UF decoder. |
|
Node for LUF which directly accesses global controller. |
|
Collection of all LUF nodes, where controller directly connects to each node. |
|
Friendship w/ neighboring nodes. |
|
Collection of all LUF nodes. |
|
Optimal waiter for |
|
Unoptimal waiter for |
|
Base class for |
- class localuf.decoders.luf.main.LUF(code, visible=True, _optimal=True)[source]¶
Bases:
BaseUFThe graph used by local UF decoder.
Extends
_BaseUF.Class attributes:
DEFAULT_X_OFFSETdefaultx_offset.Slightly larger than
constants.DEFAULT_X_OFFSETas the drawer for this class shows more information at each node.
Instance attributes (1–5 constant):
CONTROLLERa global controller object.NODESa Nodes object.VISIBLEwhether controller has direct connection w/ each node or only node w/ ID 0i.e. strictly local iff
VISIBLEisFalse. Only computed ifsyndromenot yet an attribute.
_DIGRAPH_MAKERmaker of NetworkX digraph._DECODE_DRAWERprovidesdraw_decode._FIG_WIDTHfigure width used by drawer.correctiononly exists after callingdecode()._pointer_digrapha NetworkX digraph representing the fully grown edges used by pointers,the set of its edges as directed edges, the set of its edges as undirected edges.
In drawings of this graph:
active nodes are square-shaped
inactive nodes are circular
CID is shown as a label
nodes with anyons are outlined in black
pointers are shown by arrows on edges
edges so far added to the correction are in red
the top-left node also shows the controller stage (PS stands for presyncing etc.)
- Parameters:
code (Surface)
- DEFAULT_X_OFFSET = 0.3¶
- property CONTROLLER¶
- property NODES¶
- property VISIBLE¶
- decode(syndrome, draw=False, log_history=False, **kwargs_for_draw_decode)[source]¶
Additional inputs over those of
Decoder.decode():log_historywhether to populatehistoryattribute.kwargs_for_draw_decodepassed toself.draw_decode().
- Returns tSV:
Number of timesteps to validate syndrome.
- Returns tBP:
Number of timesteps to burn and peel.
If
log_historyisTruethentSV + tBP = len(self.history).- Parameters:
syndrome (set[tuple[int, ...]])
- validate(syndrome, draw=False, log_history=False, **kwargs_for_draw_decode)[source]¶
Validate syndrome.
- Parameters:
syndrome (set[tuple[int, ...]]) – the set of defects.
draw – whether to draw.
log_history – whether to populate
historyattribute.kwargs_for_draw_decode – passed to
self.draw_decode().
- Returns:
tSV# timesteps to validate syndrome. Equalslen(self.history)iflog_historyisTrue.
- peel(log_history)[source]¶
Burn & peel after syndrome validation.
log_historywhether to populatehistoryattribute.- Returns:
tBP# timesteps to burn and peel.- Parameters:
log_history (bool)
- property syndrome¶
Syndrome computed from
self.NODES.
- draw_growth(highlighted_edges=None, highlighted_edge_color='k', unhighlighted_edge_color='#b6b6b6', x_offset=0.3, with_labels=True, labels=None, show_global=True, node_size=300, linewidths=2.0, anyon_color='k', active_shape='s', width=2.0, arrows=None, boundary_color='#9cdaed', defect_color='#Ff6666', nondefect_color='#Bef4be', show_boundary_defects=True, defect_label_color='k', **kwargs_for_networkx_draw)[source]¶
Draw growth of edges using matplotlib.
- Parameters:
growth – A dictionary where each key an edge index; value, its growth value.
syndrome – The set of defects.
highlighted_edges (set[tuple[tuple[int, ...], tuple[int, ...]]] | None) – The set of edges to be highlighted in drawing.
x_offset – The ratio of out-of-screen to along-screen distance.
with_labels – Whether to show node labels.
labels (dict[tuple[int, ...], str] | None) – A dictionary where each key a node index; value, its label as a string.
width – Line width of edges.
arrows (bool | None) – Whether to draw arrows on edges used by pointers. For
Macar, Actis, Snowflakedecoders only.kwargs_for_networkx_draw – Passed to
networkx.draw(). E.g.linewidthsline width of node symbol border.
- class localuf.decoders.luf.main.Controller(luf)[source]¶
Bases:
objectGlobal controller for LUF.
Instance attributes (1 constant):
LUFthe LUF object which has this controller.stagethe global stage.
- Parameters:
luf (LUF)
- property LUF¶
- class localuf.decoders.luf.main.Nodes(luf)[source]¶
Bases:
ABCCollection of all LUF nodes.
Instance attributes (1–2 constant):
LUFthe LUF object which has these nodes.dca dictionary where eachkey an index tuple; value, the node object at that index.
syndromethe set of defects.busyisFalseiff we are sure all nodes are ready for next stage.validisTrueiff we are sure no node is active after presyncing stagei.e.
syndromehas been validated.
_global_labelthe label of global information used by drawer.
- Parameters:
luf (LUF)
- dc: dict[tuple[int, ...], _Node]¶
- property LUF¶
- load(syndrome)[source]¶
Load syndrome onto nodes collection.
- Parameters:
syndrome (set[tuple[int, ...]])
- property syndrome¶
Compute syndrome from nodes in
dc.
- class localuf.decoders.luf.main.MacarNodes(luf)[source]¶
Bases:
NodesCollection of all LUF nodes, where controller directly connects to each node.
Extends
Nodes.- Parameters:
luf (LUF)
- property dc¶
- property busy¶
- property valid¶
- class localuf.decoders.luf.main.ActisNodes(luf, optimal=True)[source]¶
Bases:
NodesCollection of all LUF nodes, where controller only sees node whose ID is 0.
Extends
Nodes.Additional instance attributes (1–2 constant):
SPANdistance from controller to furthest node (boundary node w/ highest ID).WAITERobject which decides how long controller must wait untilit is sure no more info is being relayed (towards it).
countdowntracker used byWAITER.busy_signalwhether collection receives a busy signal in current timestep.active_signalwhether collection has received an active signal during the current syncing stage.next_{busy, active}_signalthe provisional{busy, active}_signalfor the next timestep.{busy, active}_signalhave string representations via[attribute]_signal_symbolproperty.
Notes: This decoder starts in the GROWING stage. Alternatively, could start in the SYNCING stage and in
load(), callself.update_valid()instead ofself.valid = False. This would be beneficial if noise level low enough.- Parameters:
luf (LUF)
- property dc¶
- property SPAN¶
- property WAITER¶
- property busy_signal_symbol¶
- property active_signal_symbol¶
- class localuf.decoders.luf.main.Waiter(nodes)[source]¶
Bases:
ABCBase class for
WAITERattribute ofActisNodesinstance.Instance attributes:
NODEStheActisNodesobject the waiter belongs to.RECEIVING_STARTthe value the waiter sets countdown toif it receives a busy signal during the receiving window.
- Parameters:
nodes (ActisNodes)
- RECEIVING_START: int¶
- property NODES¶
- abstract property received_busy_signal: bool¶
Whether to set
countdowntoRECEIVING_START.
- advance()[source]¶
Advance 1 timestep.
Countdown start for controller stage:
- GROWING or PRESYNCING is
spanas it takesspantimesteps (
span-1.. -1 .. 0) for information to go from controller to furthest node.
- GROWING or PRESYNCING is
- MERGING is
span+1as it takesspantimesteps (
span.. -1 .. 1) for information to go from furthest node to controller [and furthest node (which is a boundary) can be busy].
- MERGING is
- SYNCING is
spanas it takesspan-1timesteps (
span-1.. -1 .. 1) for information to go from furthest detector to controller (furthest boundary node never busy nor active).
- SYNCING is
- class localuf.decoders.luf.main.OptimalWaiter(nodes)[source]¶
Bases:
WaiterOptimal waiter for
ActisNodes.Extends
Waiter.Additional class constants:
RECEIVING_WINDOWthe countdown valuesduring which the waiter considers busy signals.
- Parameters:
nodes (ActisNodes)
- RECEIVING_WINDOW = {1, 2}¶
- RECEIVING_START: int = 2¶
- property received_busy_signal¶
Whether to set
countdowntoRECEIVING_START.
- class localuf.decoders.luf.main.UnoptimalWaiter(nodes)[source]¶
Bases:
WaiterUnoptimal waiter for
ActisNodes.Extends
Waiter.Receiving window is the entire countdown i.e. always.
- Parameters:
nodes (ActisNodes)
- property received_busy_signal¶
Whether to set
countdowntoRECEIVING_START.
- class localuf.decoders.luf.main.MacarNode(nodes, index)[source]¶
Bases:
_NodeNode for LUF which directly accesses global controller.
Extends
_Node.- Parameters:
nodes (Nodes)
index (tuple[int, ...])
- class localuf.decoders.luf.main.ActisNode(nodes, index)[source]¶
Bases:
_NodeNode for LUF w/o direct access to blind global controller.
Extends
_Node.Additional instance attributes (1–2 constant):
SPANthe countdown start of the node.FRIENDSHIPthe type of connection the node has for communicatingstageand signal information.
countdowntracks how long node must wait until staging is donei.e. when all nodes have same stage, when
stagein {GROWING, PRESYNCING}.
stagenode stage.busy_signalif in the current timestep the node eitheris busy or receives a busy signal from another node.
active_signalif in the current timestep the node eitherhas
stageaspresyncingand becomes active, or receives an active signal from another node.
next_{stage, {busy, active}_signal}the provisional{stage, {busy, active}_signal}for the next timestep.stage, {busy, active}_signalhave string representations via[attribute]_symbolproperty.
- Parameters:
nodes (ActisNodes)
index (tuple[int, ...])
- property NODES¶
- property SPAN¶
- property FRIENDSHIP¶
- property stage_symbol¶
- property busy_signal_symbol¶
- property active_signal_symbol¶
- advance_definite(stage)[source]¶
Advance when
stagein{'growing', 'presyncing'}.- Parameters:
stage (str)
- advance_indefinite(stage)[source]¶
Advance when
stagein{'merging', 'syncing'}.- Parameters:
stage (str)
- presyncing()[source]¶
Initialise for syncing stage i.e. update after merge stage.
If node the root of an active cluster, set
active,active_signaltoTrue; else, set both toFalse.
- class localuf.decoders.luf.main.Friendship(node)[source]¶
Bases:
ABCThe type of connection for communicating
stage, {busy, active}_signalinformation.Instance attributes (1 constant):
NODEthe node which has this friendship.
- Parameters:
node (ActisNode)
- property NODE¶
- abstractmethod update_stage()[source]¶
Update stage depending on neighbors and return whether stage changed.
- Return type:
bool
- update_stage_helper(relayee)[source]¶
Update stage based on stage of component
relayee.- Parameters:
relayee (Controller | ActisNode)
- class localuf.decoders.luf.main.ControllerFriendship(node)[source]¶
Bases:
FriendshipFriendship w/ controller.
Extends
Friendship. Only node whose ID is 0 has this friendship. Note this node never busy.- Parameters:
node (ActisNode)
- class localuf.decoders.luf.main.NodeFriendship(node)[source]¶
Bases:
FriendshipFriendship w/ neighboring nodes.
Extends
Friendship.Additional instance attributes (1 constant):
RELAYEEthe neighboring node thatbusy_signalis sent to.Equals the neighbor in the direction toward node of ID 0.
- Parameters:
node (ActisNode)
- property RELAYEE: tuple[int, ...]¶