netqasm.lang.instr

netqasm.lang.instr.base

class netqasm.lang.instr.base.NetQASMInstruction(id=- 1, mnemonic='', lineno=None)

Bases: abc.ABC

Base NetQASM instruction class.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

id: int = -1
mnemonic: str = ''
lineno: Optional[netqasm.util.log.HostLine] = None
abstract property operands
Return type

List[Operand]

abstract classmethod deserialize_from(raw)
Parameters

raw (bytes) –

Return type

NetQASMInstruction

abstract serialize()
Return type

bytes

abstract classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

Return type

NetQASMInstruction

writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

property debug_str
class netqasm.lang.instr.base.NoOperandInstruction(id=- 1, mnemonic='', lineno=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with no operands.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegInstruction(id=- 1, mnemonic='', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Register operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

reg: netqasm.lang.operand.Register = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegRegInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 2 Register operands.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegImmImmInstruction(id=- 1, mnemonic='', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Register operand followed by 2 Immediate operands.

Parameters
reg: netqasm.lang.operand.Register = None
imm0: netqasm.lang.operand.Immediate = None
imm1: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegRegImmImmInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 2 Register operands followed by 2 Immediate operands.

Parameters
reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
imm0: netqasm.lang.operand.Immediate = None
imm1: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegRegRegInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, reg2=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 3 Register operands.

Parameters
reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
reg2: netqasm.lang.operand.Register = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegRegRegRegInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 4 Register operands.

Parameters
reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
reg2: netqasm.lang.operand.Register = None
reg3: netqasm.lang.operand.Register = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.ImmInstruction(id=- 1, mnemonic='', lineno=None, imm=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Immediate operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • imm (Optional[Immediate]) –

imm: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.ImmImmInstruction(id=- 1, mnemonic='', lineno=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 2 Immediate operands.

Parameters
imm0: netqasm.lang.operand.Immediate = None
imm1: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegRegImmInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 2 Register operands and one Immediate operand.

Parameters
reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
imm: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegImmInstruction(id=- 1, mnemonic='', lineno=None, reg=None, imm=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Register operand and one Immediate operand.

Parameters
reg: netqasm.lang.operand.Register = None
imm: netqasm.lang.operand.Immediate = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegEntryInstruction(id=- 1, mnemonic='', lineno=None, reg=None, entry=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Register operand and one ArrayEntry operand.

Parameters
reg: netqasm.lang.operand.Register = None
entry: netqasm.lang.operand.ArrayEntry = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.RegAddrInstruction(id=- 1, mnemonic='', lineno=None, reg=None, address=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Register operand and one Address operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

  • address (Optional[Address]) –

reg: netqasm.lang.operand.Register = None
address: netqasm.lang.operand.Address = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.ArrayEntryInstruction(id=- 1, mnemonic='', lineno=None, entry=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 ArrayEntry operand and one Address operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • entry (Optional[ArrayEntry]) –

entry: netqasm.lang.operand.ArrayEntry = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.ArraySliceInstruction(id=- 1, mnemonic='', lineno=None, slice=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 ArraySlice operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • slice (Optional[ArraySlice]) –

slice: netqasm.lang.operand.ArraySlice = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.AddrInstruction(id=- 1, mnemonic='', lineno=None, address=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 1 Address operand.

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • address (Optional[Address]) –

address: netqasm.lang.operand.Address = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.Reg5Instruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None, reg4=None)

Bases: netqasm.lang.instr.base.NetQASMInstruction

An instruction with 5 Register operands.

Parameters
reg0: netqasm.lang.operand.Register = None
reg1: netqasm.lang.operand.Register = None
reg2: netqasm.lang.operand.Register = None
reg3: netqasm.lang.operand.Register = None
reg4: netqasm.lang.operand.Register = None
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

class netqasm.lang.instr.base.DebugInstruction(id=- 1, mnemonic='', lineno=None, text='')

Bases: netqasm.lang.instr.base.NetQASMInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • text (str) –

text: str = ''
property operands
Return type

List[Operand]

classmethod deserialize_from(raw)
Parameters

raw (bytes) –

serialize()
Return type

bytes

classmethod from_operands(operands)
Parameters

operands (List[Operand]) –

netqasm.lang.instr.core

class netqasm.lang.instr.core.SingleQubitInstruction(id=- 1, mnemonic='', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.RegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

property qreg
abstract to_matrix()
Return type

ndarray

class netqasm.lang.instr.core.TwoQubitInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.base.RegRegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

property qreg0
property qreg1
abstract to_matrix()
abstract to_matrix_target_only()
class netqasm.lang.instr.core.RotationInstruction(id=- 1, mnemonic='', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.RegImmImmInstruction

Parameters
property qreg
property angle_num
property angle_denom
abstract to_matrix()
class netqasm.lang.instr.core.ControlledRotationInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.RegRegImmImmInstruction

Parameters
property qreg0
property qreg1
property angle_num
property angle_denom
abstract to_matrix()
class netqasm.lang.instr.core.ClassicalOpInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, reg2=None)

Bases: netqasm.lang.instr.base.RegRegRegInstruction

Parameters
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

property regout
property regin0
property regin1
class netqasm.lang.instr.core.ClassicalOpModInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None)

Bases: netqasm.lang.instr.base.RegRegRegRegInstruction

Parameters
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

property regout
property regin0
property regin1
property regmod
class netqasm.lang.instr.core.QAllocInstruction(id=1, mnemonic='qalloc', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.RegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 1
mnemonic: str = 'qalloc'
property qreg
class netqasm.lang.instr.core.InitInstruction(id=2, mnemonic='init', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.RegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 2
mnemonic: str = 'init'
property qreg
class netqasm.lang.instr.core.ArrayInstruction(id=3, mnemonic='array', lineno=None, reg=None, address=None)

Bases: netqasm.lang.instr.base.RegAddrInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

  • address (Optional[Address]) –

id: int = 3
mnemonic: str = 'array'
property size
class netqasm.lang.instr.core.SetInstruction(id=4, mnemonic='set', lineno=None, reg=None, imm=None)

Bases: netqasm.lang.instr.base.RegImmInstruction

Parameters
id: int = 4
mnemonic: str = 'set'
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

class netqasm.lang.instr.core.StoreInstruction(id=5, mnemonic='store', lineno=None, reg=None, entry=None)

Bases: netqasm.lang.instr.base.RegEntryInstruction

Parameters
id: int = 5
mnemonic: str = 'store'
class netqasm.lang.instr.core.LoadInstruction(id=6, mnemonic='load', lineno=None, reg=None, entry=None)

Bases: netqasm.lang.instr.base.RegEntryInstruction

Parameters
id: int = 6
mnemonic: str = 'load'
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

class netqasm.lang.instr.core.UndefInstruction(id=7, mnemonic='undef', lineno=None, entry=None)

Bases: netqasm.lang.instr.base.ArrayEntryInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • entry (Optional[ArrayEntry]) –

id: int = 7
mnemonic: str = 'undef'
class netqasm.lang.instr.core.LeaInstruction(id=8, mnemonic='lea', lineno=None, reg=None, address=None)

Bases: netqasm.lang.instr.base.RegAddrInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

  • address (Optional[Address]) –

id: int = 8
mnemonic: str = 'lea'
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

class netqasm.lang.instr.core.JmpInstruction(id=9, mnemonic='jmp', lineno=None, imm=None)

Bases: netqasm.lang.instr.base.ImmInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • imm (Optional[Immediate]) –

id: int = 9
mnemonic: str = 'jmp'
property line
class netqasm.lang.instr.core.BranchUnaryInstruction(id=- 1, mnemonic='', lineno=None, reg=None, imm=None)

Bases: netqasm.lang.instr.base.RegImmInstruction

Represents an instruction to branch to a certain line, depending on a unary expression.

Parameters
property line
abstract check_condition(a)
Return type

bool

class netqasm.lang.instr.core.BezInstruction(id=10, mnemonic='bez', lineno=None, reg=None, imm=None)

Bases: netqasm.lang.instr.core.BranchUnaryInstruction

Parameters
id: int = 10
mnemonic: str = 'bez'
check_condition(a)
Parameters

a (int) –

Return type

bool

class netqasm.lang.instr.core.BnzInstruction(id=11, mnemonic='bnz', lineno=None, reg=None, imm=None)

Bases: netqasm.lang.instr.core.BranchUnaryInstruction

Parameters
id: int = 11
mnemonic: str = 'bnz'
check_condition(a)
Parameters

a (int) –

Return type

bool

class netqasm.lang.instr.core.BranchBinaryInstruction(id=- 1, mnemonic='', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.base.RegRegImmInstruction

Represents an instruction to branch to a certain line, depending on a binary expression.

Parameters
property line
abstract check_condition(a, b)
Return type

bool

class netqasm.lang.instr.core.BeqInstruction(id=12, mnemonic='beq', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.core.BranchBinaryInstruction

Parameters
id: int = 12
mnemonic: str = 'beq'
check_condition(a, b)
Parameters
  • a (int) –

  • b (int) –

Return type

bool

class netqasm.lang.instr.core.BneInstruction(id=13, mnemonic='bne', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.core.BranchBinaryInstruction

Parameters
id: int = 13
mnemonic: str = 'bne'
check_condition(a, b)
Parameters
  • a (int) –

  • b (int) –

Return type

bool

class netqasm.lang.instr.core.BltInstruction(id=14, mnemonic='blt', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.core.BranchBinaryInstruction

Parameters
id: int = 14
mnemonic: str = 'blt'
check_condition(a, b)
Parameters
  • a (int) –

  • b (int) –

Return type

bool

class netqasm.lang.instr.core.BgeInstruction(id=15, mnemonic='bge', lineno=None, reg0=None, reg1=None, imm=None)

Bases: netqasm.lang.instr.core.BranchBinaryInstruction

Parameters
id: int = 15
mnemonic: str = 'bge'
check_condition(a, b)
Parameters
  • a (int) –

  • b (int) –

Return type

bool

class netqasm.lang.instr.core.AddInstruction(id=16, mnemonic='add', lineno=None, reg0=None, reg1=None, reg2=None)

Bases: netqasm.lang.instr.core.ClassicalOpInstruction

Parameters
id: int = 16
mnemonic: str = 'add'
class netqasm.lang.instr.core.SubInstruction(id=17, mnemonic='sub', lineno=None, reg0=None, reg1=None, reg2=None)

Bases: netqasm.lang.instr.core.ClassicalOpInstruction

Parameters
id: int = 17
mnemonic: str = 'sub'
class netqasm.lang.instr.core.AddmInstruction(id=18, mnemonic='addm', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None)

Bases: netqasm.lang.instr.core.ClassicalOpModInstruction

Parameters
id: int = 18
mnemonic: str = 'addm'
class netqasm.lang.instr.core.SubmInstruction(id=19, mnemonic='subm', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None)

Bases: netqasm.lang.instr.core.ClassicalOpModInstruction

Parameters
id: int = 19
mnemonic: str = 'subm'
class netqasm.lang.instr.core.MeasInstruction(id=32, mnemonic='meas', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.base.RegRegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

id: int = 32
mnemonic: str = 'meas'
writes_to()

Returns a list of Registers that this instruction writes to

Return type

List[Register]

property qreg
property creg
class netqasm.lang.instr.core.CreateEPRInstruction(id=33, mnemonic='create_epr', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None, reg4=None)

Bases: netqasm.lang.instr.base.Reg5Instruction

Parameters
id: int = 33
mnemonic: str = 'create_epr'
property remote_node_id
property epr_socket_id
property qubit_addr_array
property arg_array
property ent_results_array
class netqasm.lang.instr.core.RecvEPRInstruction(id=34, mnemonic='recv_epr', lineno=None, reg0=None, reg1=None, reg2=None, reg3=None)

Bases: netqasm.lang.instr.base.RegRegRegRegInstruction

Parameters
id: int = 34
mnemonic: str = 'recv_epr'
property remote_node_id
property epr_socket_id
property qubit_addr_array
property ent_results_array
class netqasm.lang.instr.core.WaitAllInstruction(id=35, mnemonic='wait_all', lineno=None, slice=None)

Bases: netqasm.lang.instr.base.ArraySliceInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • slice (Optional[ArraySlice]) –

id: int = 35
mnemonic: str = 'wait_all'
class netqasm.lang.instr.core.WaitAnyInstruction(id=36, mnemonic='wait_any', lineno=None, slice=None)

Bases: netqasm.lang.instr.base.ArraySliceInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • slice (Optional[ArraySlice]) –

id: int = 36
mnemonic: str = 'wait_any'
class netqasm.lang.instr.core.WaitSingleInstruction(id=37, mnemonic='wait_single', lineno=None, entry=None)

Bases: netqasm.lang.instr.base.ArrayEntryInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • entry (Optional[ArrayEntry]) –

id: int = 37
mnemonic: str = 'wait_single'
class netqasm.lang.instr.core.QFreeInstruction(id=38, mnemonic='qfree', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.RegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 38
mnemonic: str = 'qfree'
property qreg
class netqasm.lang.instr.core.RetRegInstruction(id=39, mnemonic='ret_reg', lineno=None, reg=None)

Bases: netqasm.lang.instr.base.RegInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 39
mnemonic: str = 'ret_reg'
class netqasm.lang.instr.core.RetArrInstruction(id=40, mnemonic='ret_arr', lineno=None, address=None)

Bases: netqasm.lang.instr.base.AddrInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • address (Optional[Address]) –

id: int = 40
mnemonic: str = 'ret_arr'
class netqasm.lang.instr.core.BreakpointInstruction(id=100, mnemonic='breakpoint', lineno=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.base.ImmImmInstruction

Parameters
id: int = 100
mnemonic: str = 'breakpoint'
property action
property role

netqasm.lang.instr.flavour

class netqasm.lang.instr.flavour.InstrMap(id_map=None, name_map=None)

Bases: object

Parameters
id_map: Optional[Dict[int, Type[netqasm.lang.instr.base.NetQASMInstruction]]] = None
name_map: Optional[Dict[str, Type[netqasm.lang.instr.base.NetQASMInstruction]]] = None
class netqasm.lang.instr.flavour.Flavour(flavour_specific)

Bases: abc.ABC

A Flavour represents an explicit instruction set that adheres to the Core NetQASM specification. Typically, a flavour is used for each specific target hardware.

A flavour ‘inherits’ all classical instructions from the core, but can specify explicitly the quantum instructions that the hardware supports, by listing the corresponding instruction classes.

Examples of flavours are the Vanilla flavour (with instructions defined in vanilla.py) and the Nitrogen-Vacancy (NV) flavour (instructions in nv.py).

Parameters

flavour_specific (List[Type[NetQASMInstruction]]) –

get_instr_by_id(id)
Parameters

id (int) –

get_instr_by_name(name)
Parameters

name (str) –

abstract property instrs
class netqasm.lang.instr.flavour.VanillaFlavour

Bases: netqasm.lang.instr.flavour.Flavour

property instrs
class netqasm.lang.instr.flavour.NVFlavour

Bases: netqasm.lang.instr.flavour.Flavour

property instrs

netqasm.lang.instr.nv

class netqasm.lang.instr.nv.GateXInstruction(id=20, mnemonic='x', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 20
mnemonic: str = 'x'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.GateYInstruction(id=21, mnemonic='y', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 21
mnemonic: str = 'y'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.GateZInstruction(id=22, mnemonic='z', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 22
mnemonic: str = 'z'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.GateHInstruction(id=23, mnemonic='h', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 23
mnemonic: str = 'h'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.RotXInstruction(id=27, mnemonic='rot_x', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 27
mnemonic: str = 'rot_x'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.RotYInstruction(id=28, mnemonic='rot_y', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 28
mnemonic: str = 'rot_y'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.RotZInstruction(id=29, mnemonic='rot_z', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 29
mnemonic: str = 'rot_z'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.nv.ControlledRotXInstruction(id=30, mnemonic='crot_x', lineno=None, reg0=None, reg1=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.ControlledRotationInstruction

Parameters
id: int = 30
mnemonic: str = 'crot_x'
to_matrix()
Return type

ndarray

to_matrix_target_only()
Return type

ndarray

class netqasm.lang.instr.nv.ControlledRotYInstruction(id=31, mnemonic='crot_y', lineno=None, reg0=None, reg1=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.ControlledRotationInstruction

Parameters
id: int = 31
mnemonic: str = 'crot_y'
to_matrix()
Return type

ndarray

to_matrix_target_only()
Return type

ndarray

netqasm.lang.instr.vanilla

class netqasm.lang.instr.vanilla.GateXInstruction(id=20, mnemonic='x', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 20
mnemonic: str = 'x'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateYInstruction(id=21, mnemonic='y', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 21
mnemonic: str = 'y'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateZInstruction(id=22, mnemonic='z', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 22
mnemonic: str = 'z'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateHInstruction(id=23, mnemonic='h', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 23
mnemonic: str = 'h'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateSInstruction(id=24, mnemonic='s', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 24
mnemonic: str = 's'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateKInstruction(id=25, mnemonic='k', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 25
mnemonic: str = 'k'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.GateTInstruction(id=26, mnemonic='t', lineno=None, reg=None)

Bases: netqasm.lang.instr.core.SingleQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg (Optional[Register]) –

id: int = 26
mnemonic: str = 't'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.RotXInstruction(id=27, mnemonic='rot_x', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 27
mnemonic: str = 'rot_x'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.RotYInstruction(id=28, mnemonic='rot_y', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 28
mnemonic: str = 'rot_y'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.RotZInstruction(id=29, mnemonic='rot_z', lineno=None, reg=None, imm0=None, imm1=None)

Bases: netqasm.lang.instr.core.RotationInstruction

Parameters
id: int = 29
mnemonic: str = 'rot_z'
to_matrix()
Return type

ndarray

class netqasm.lang.instr.vanilla.CnotInstruction(id=30, mnemonic='cnot', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.core.TwoQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

id: int = 30
mnemonic: str = 'cnot'
to_matrix()
Return type

ndarray

to_matrix_target_only()
Return type

ndarray

class netqasm.lang.instr.vanilla.CphaseInstruction(id=31, mnemonic='cphase', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.core.TwoQubitInstruction

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

id: int = 31
mnemonic: str = 'cphase'
to_matrix()
Return type

ndarray

to_matrix_target_only()
Return type

ndarray

class netqasm.lang.instr.vanilla.MovInstruction(id=41, mnemonic='mov', lineno=None, reg0=None, reg1=None)

Bases: netqasm.lang.instr.core.TwoQubitInstruction

Move source qubit to target qubit (target is overwritten)

Parameters
  • id (int) –

  • mnemonic (str) –

  • lineno (Optional[HostLine]) –

  • reg0 (Optional[Register]) –

  • reg1 (Optional[Register]) –

id: int = 41
mnemonic: str = 'mov'
to_matrix()
Return type

ndarray

to_matrix_target_only()
Return type

ndarray