ISAContext Class

Context passed through enumeration, holding shared state.

Initialize the ISA context for the given architecture.

Constructor

ISAContext(arch: Architecture)

Parameters

Name Description
arch
Required

The architecture providing the base ISA.

Methods

add_instruction

Create an instruction and add it to the provenance graph.

Can be called in two ways:

  1. With keyword args to create a new instruction:

    
       ctx.add_instruction(T, encoding=LOGICAL, time=1000,
                           error_rate=1e-8)
    
  2. With a pre-existing Instruction object (e.g. from with_id()):

    
       ctx.add_instruction(existing_instruction)
    

Provenance is recorded when transform and/or source are supplied:

  • transform — the ISATransform that produced the instruction.

  • source — input instructions consumed by the transform.

make_isa

Create an ISA backed by this context's provenance graph from the given node indices.

add_instruction

Create an instruction and add it to the provenance graph.

Can be called in two ways:

  1. With keyword args to create a new instruction:

    
       ctx.add_instruction(T, encoding=LOGICAL, time=1000,
                           error_rate=1e-8)
    
  2. With a pre-existing Instruction object (e.g. from with_id()):

    
       ctx.add_instruction(existing_instruction)
    

Provenance is recorded when transform and/or source are supplied:

  • transform — the ISATransform that produced the instruction.

  • source — input instructions consumed by the transform.

add_instruction(id_or_instruction: int | Instruction, encoding: Encoding = 0, *, arity: int | None = 1, time: int | _IntFunction = 0, space: int | None | _IntFunction = None, length: int | _IntFunction | None = None, error_rate: float | _FloatFunction = 0.0, transform: ISATransform | None = None, source: list[Instruction] | None = None, **kwargs: int) -> int

Parameters

Name Description
id_or_instruction
Required

Either an instruction ID (int) for creating a new instruction, or an existing Instruction object.

encoding

The instruction encoding (0 = Physical, 1 = Logical). Ignored when passing an existing Instruction.

Default value: 0
arity
Required

The instruction arity. None for variable arity. Ignored when passing an existing Instruction.

time
Required

Instruction time in ns (or _IntFunction for variable arity). Ignored when passing an existing Instruction.

space
Required

Instruction space in physical qubits (or _IntFunction for variable arity). Ignored when passing an existing Instruction.

length
Required

Arity including ancilla qubits. Ignored when passing an existing Instruction.

error_rate
Required

Instruction error rate (or _FloatFunction for variable arity). Ignored when passing an existing Instruction.

transform
Required

The ISATransform that produced the instruction.

source
Required

List of source Instruction objects consumed by the transform.

**kwargs
Required

Additional properties (e.g. distance=9). Ignored when passing an existing Instruction.

Keyword-Only Parameters

Name Description
arity
Default value: 1
time
Default value: 0
space
Default value: None
length
Default value: None
error_rate
Default value: 0.0
transform
Default value: None
source
Default value: None

Returns

Type Description

The node index in the provenance graph.

Exceptions

Type Description

If an unknown property name is provided in kwargs.

make_isa

Create an ISA backed by this context's provenance graph from the given node indices.

make_isa(*node_indices: int) -> ISA

Parameters

Name Description
*node_indices
Required
int

Node indices in the provenance graph.

Returns

Type Description
ISA

An ISA referencing the provenance graph.

Attributes

isa

The ISA provided by the architecture for this context.