netqasm.backend.messages

Definitions of messages between the Host and the quantum node controller.

class netqasm.backend.messages.MessageHeader

Bases: _ctypes.Structure

classmethod len()
id

Structure/Union member

length

Structure/Union member

class netqasm.backend.messages.MessageType(value)

Bases: enum.Enum

An enumeration.

INIT_NEW_APP = 0
OPEN_EPR_SOCKET = 1
SUBROUTINE = 2
STOP_APP = 3
SIGNAL = 4
class netqasm.backend.messages.Message

Bases: _ctypes.Structure

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.InitNewAppMessage(app_id=0, max_qubits=0)

Bases: netqasm.backend.messages.Message

Message sent to the quantum node controller to register a new application.

TYPE = 0
app_id

Structure/Union member

max_qubits

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.OpenEPRSocketMessage(app_id=0, epr_socket_id=0, remote_node_id=0, remote_epr_socket_id=0, min_fidelity=100)

Bases: netqasm.backend.messages.Message

Message sent to the quantum node controller to open an EPR socket.

TYPE = 1
app_id

Structure/Union member

epr_socket_id

Structure/Union member

remote_node_id

Structure/Union member

remote_epr_socket_id

Structure/Union member

min_fidelity

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.SubroutineMessage(subroutine)

Bases: object

Message sent to the quantum node controller to execute a subroutine.

Parameters

subroutine (Union[bytes, Subroutine]) –

TYPE = 2
__init__(subroutine)

NOTE this message does not subclass from Message since it contains a subroutine which is defined separately and not as a ctype for now. Still this class defines the methods __bytes__ and deserialize_from so that it can be packed and unpacked. The packed form of the message is:

| TYP | SUBROUTINE ... |
Parameters

subroutine (Union[bytes, Subroutine]) –

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

class netqasm.backend.messages.StopAppMessage(app_id=0)

Bases: netqasm.backend.messages.Message

Message sent to the quantum node controller to stop/finish an application.

TYPE = 3
app_id

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.Signal(value)

Bases: enum.Enum

An enumeration.

STOP = 0
class netqasm.backend.messages.SignalMessage(signal=<Signal.STOP: 0>)

Bases: netqasm.backend.messages.Message

Message sent to the quantum node controller with a specific signal.

Currently only used with the SquidASM simulator backend.

Parameters

signal (Signal) –

TYPE = 4
signal

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

netqasm.backend.messages.deserialize_host_msg(raw)

Convert a serialized message into a Message object

Parameters

raw (bytes) – serialized message (string of bytes)

Return type

Message

Returns

deserialized message object

class netqasm.backend.messages.ReturnMessage

Bases: netqasm.backend.messages.Message

Base class for messages from the quantum node controller to the Host.

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.ReturnMessageType(value)

Bases: enum.Enum

An enumeration.

DONE = 0
ERR = 1
RET_ARR = 2
RET_REG = 3
class netqasm.backend.messages.MsgDoneMessage(msg_id=0)

Bases: netqasm.backend.messages.ReturnMessage

Message to the Host that a subroutine has finished.

TYPE = 0
msg_id

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.ErrorCode(value)

Bases: enum.Enum

An enumeration.

GENERAL = 0
NO_QUBIT = 1
UNSUPP = 2
class netqasm.backend.messages.ErrorMessage(err_code)

Bases: netqasm.backend.messages.ReturnMessage

Message to the Host that an error occurred at the quantum node controller.

TYPE = 1
err_code

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

class netqasm.backend.messages.ReturnArrayMessageHeader

Bases: _ctypes.Structure

Header for a message with a returned array coming from the quantum node controller.

classmethod len()
address

Structure/Union member

length

Structure/Union member

class netqasm.backend.messages.ReturnArrayMessage(address, values)

Bases: object

Message with a returned array coming from the quantum node controller.

TYPE = 2
__init__(address, values)

NOTE this message does not subclass from ReturnMessage since the values is of variable length. Still this class defines the methods __bytes__ and deserialize_from so that it can be packed and unpacked.

The packed form of the message is:

| ADDRESS | LENGTH | VALUES ... |
classmethod deserialize_from(raw)
Parameters

raw (bytes) –

class netqasm.backend.messages.ReturnRegMessage(register, value)

Bases: netqasm.backend.messages.ReturnMessage

Message with a returned register coming from the quantum node controller.

TYPE = 3
register

Structure/Union member

value

Structure/Union member

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

type

Structure/Union member

netqasm.backend.messages.deserialize_return_msg(raw)

Convert a serialized ‘return’ message into a Message object

Parameters

raw (bytes) – serialized message (string of bytes)

Return type

Message

Returns

deserialized message object