loom.cliffordsim.moments.instruction
Copyright (c) Entropica Labs Pte Ltd 2025.
Use, distribution and reproduction of this program in its source or compiled form is prohibited without the express written consent of Entropica Labs Pte Ltd.
- class loom.cliffordsim.moments.instruction.AddQubitDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe AddQubitDecorator adds a qubit to the quantum state. If the index exists in the current quantum state, the new qubit will be inserted at the index while the existing qubits with an index larger than the inserted qubits index will have their index increased by 1.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (AddQubit) – The AddQubit Operation that will be applied.
- index
The index of the qubit to be added.
- Type:
int
- static apply_add_qubit_pf(input_pauliframes, index)[source]
Applies an AddQubit operation to a list of PauliFrames. A staticmethod that applies an AddQubit operation to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.CNOTDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe CNOTDecorator applies a CNOT, Controlled-NOT, gate across 2 qubits, a control qubit and a target qubit.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.CNOT) – The CNOT Operation that will be applied.
- c_qubit
The control qubit that controls the CNOT gate.
- Type:
int
- t_qubit
The target qubit where the NOT/X gate will be applied if the control qubit is 1.
- Type:
int
- static apply_cnot_pf(input_pauliframes, c_qubit, t_qubit)[source]
A staticmethod that applies a CNOT gate to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.CYDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe CYDecorator applies a CY, Controlled-Y, gate across 2 qubits, a control qubit and a target qubit.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.CY) – The CY Operation that will be applied.
- c_qubit
The control qubit that controls the CY gate.
- Type:
int
- t_qubit
The target qubit where the Y gate will be applied if the control qubit is 1.
- Type:
int
- static apply_cy_pf(input_pauliframes, c_qubit, t_qubit)[source]
A staticmethod that applies a CY gate to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.CZDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe CZDecorator applies a CZ, Controlled-Z, gate across 2 qubits, a control qubit and a target qubit.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.CZ) – The CZ Operation that will be applied.
- c_qubit
The control qubit that controls the CZ gate.
- Type:
int
- t_qubit
The target qubit where the Z gate will be applied if the control qubit is 1.
- Type:
int
- static apply_cz_pf(input_pauliframes, c_qubit, t_qubit)[source]
A staticmethod that applies a CZ gate to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ClassicalANDDecorator(instruction, input_operation)[source]
Bases:
ClassicalBitDecoratorThe ClassicalANDDecorator applies a bitwise AND operation to two bits in a classical register and stores the result in another bit in the same register. (If the output bit exists, it will be overwritten)
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (ClassicalAND) – The ClassicalAND Operation that will be applied.
- reg_name
The name of the classical register.
- Type:
str
- input_bit_order
The order of the input bits in the classical register.
- Type:
List[int]
- input_bit_ids
The IDs of the input bits in the classical register.
- Type:
List[int]
- output_reg_name
The name of the classical register where the output bit is stored.
- Type:
str
- write_bit_order
The order of the output bit in the classical register.
- Type:
int
- write_bit_id
The ID of the output bit in the classical register.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ClassicalBitDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe ClassicalBitDecorator contains private methods to get information about a bit in a classical register, these methods will be used by its subclasses.
Any InstructionDecorator that involves classical bits should inherit from this class.
- class loom.cliffordsim.moments.instruction.ClassicalNOTDecorator(instruction, input_operation)[source]
Bases:
ClassicalBitDecoratorThe ClassicalNOTDecorator applies a NOT operation to a bit in a classical register.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (ClassicalNOT) – The ClassicalNOT Operation that will be applied.
- reg_name
The name of the classical register.
- Type:
str
- bit_order
The order of the bit in the classical register.
- Type:
int
- bit_id
The ID of the bit in the classical register.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ClassicalORDecorator(instruction, input_operation)[source]
Bases:
ClassicalBitDecoratorThe ClassicalORDecorator applies a bitwise OR operation to two bits in a classical register and stores the result in another bit in the same register. (If the output bit exists, it will be overwritten)
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (ClassicalOR) – The ClassicalOR Operation that will be applied.
- reg_name
The name of the classical register.
- Type:
str
- input_bit_order
The order of the input bits in the classical register.
- Type:
List[int]
- input_bit_ids
The IDs of the input bits in the classical register.
- Type:
List[int]
- output_reg_name
The name of the classical register where the output bit is stored.
- Type:
str
- write_bit_order
The order of the output bit in the classical register.
- Type:
int
- write_bit_id
The ID of the output bit in the classical register.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ControlledOperationDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe ControlledOperationDecorator allows the user to transform an Operation into a Controlled Operation conditioned on a bit in the classical register. The operation is applied if the control bit is 1.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (ControlledOperation) – The ControlledOperation Operation that will be applied. The information about the conditioned classical bit and the operation to be applied is stored in the app_operation of the ControlledOperation.
- app_operation
The operation to be applied.
- reg_name
The name of the classical register.
- Type:
str
- bit_order
The order of the bit in the classical register.
- Type:
int
- bit_id
The ID of the bit in the classical register.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.CreateClassicalRegisterDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe CreateClassicalRegisterDecorator creates a new classical register and adds it to the registry in the Engine at runtime.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (CreateClassicalRegister) – The CreateClassicalRegister Operation that will be applied.
- reg_name
The name of the classical register.
- Type:
str
- no_of_bits
The number of bits in the classical register.
- Type:
int
- bit_ids
The IDs of the bits in the classical register.
- Type:
List[int]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.CreatePauliFrameDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe CreatePauliFrameDecorator creates a new PauliFrame object and adds it to the list of propagating PauliFrames at runtime.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (CreatePauliFrame) – The CreatePauliFrame Operation that will be applied.
- pauli_frame
The PauliFrame object to be created.
- Type:
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.DecoratorSelector(*values)[source]
Bases:
EnumThe Decorator Selector chooses which Decorator to call based on the name of the input Operation. Decorators should not be selected directly other than through this selector.
- AddQubit(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.AddQubitDecorator'>
- CNOT(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.CNOTDecorator'>
- CY(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.CYDecorator'>
- CZ(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.CZDecorator'>
- ClassicalAND(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ClassicalANDDecorator'>
- ClassicalNOT(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ClassicalNOTDecorator'>
- ClassicalOR(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ClassicalORDecorator'>
- ControlledOperation(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ControlledOperationDecorator'>
- CreateClassicalRegister(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.CreateClassicalRegisterDecorator'>
- CreatePauliFrame(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.CreatePauliFrameDecorator'>
- DeleteQubit(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.DeleteQubitDecorator'>
- Hadamard(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.HadamardDecorator'>
- Identity(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.IdentityDecorator'>
- Measurement(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.MeasurementDecorator'>
- Phase(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.PhaseDecorator'>
- PhaseInv(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.PhaseInvDecorator'>
- RecordClassicalRegister(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.RecordClassicalRegisterDecorator'>
- RecordPauliFrame(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.RecordPauliFrameDecorator'>
- Reset(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ResetDecorator'>
- SWAP(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.SWAPDecorator'>
- UpdateTableau(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.UpdateTableauDecorator'>
- X(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.XDecorator'>
- Y(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.YDecorator'>
- Z(instruction, input_operation) = <class 'loom.cliffordsim.moments.instruction.ZDecorator'>
- class loom.cliffordsim.moments.instruction.DeleteQubitDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe DeleteQubitDecorator deletes a qubit from the quantum state. If the index exists in the current quantum state, the qubit will be removed from the state while the existing qubits with an index larger than the deleted qubits index will have their index decreased by 1.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (DeleteQubit) – The DeleteQubit Operation that will be applied.
- qubit
The qubit to be deleted.
- Type:
int
- static apply_delete_qubit_pf(input_pauliframes, index)[source]
A staticmethod that applies a DeleteQubit operation to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.HadamardDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe HadamardDecorator applies a Hadamard gate to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Hadamard) – The Hadamard Operation that will be applied.
- qubit
The qubit to apply the Hadamard gate to.
- Type:
int
- static apply_hadamard(input_tableau, qubit)[source]
Applies a hadamard gate on a specific qubit.
- Parameters:
input_tableau (Tableau) – The input representation of the quantum state.
qubit (int) – The qubit to apply the Hadamard gate to.
- static apply_hadamard_pf(input_pauliframes, qubit)[source]
Applies a Hadamard gate on a specific qubit in a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.IdentityDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe IdentityDecorator returns the input Tableau or PauliFrames without any modifications.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Identity) – The Identity Operation that will be applied.
- qubit
The qubit to apply the Identity gate to.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.IdentityInstruction[source]
Bases:
InstructionA simple Instruction that does nothing. This will be the initial Instruction in a Moment. Other Instructions within the Moment will decorate this Instruction.
- apply(input_tableau, data_store, **kwargs)[source]
Applies the quantum operation to the input Tableau.
- apply_pf(input_pauliframes, data_store, **kwargs)[source]
Propagates the PauliFrames forward through the quantum operation.
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- apply_pf_back(input_pauliframes, data_store, **kwargs)[source]
Propagates the PauliFrames backward through the quantum operation.
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- class loom.cliffordsim.moments.instruction.Instruction[source]
Bases:
objectAn Instruction contains the implementation logic for a quantum operation.
Every Instruction requires an apply method for Tableau-based simulations, and a apply_pf and apply_pf_back method for PauliFrame-based simulations.
PauliFrame simulations can be performed by propagating a PauliFrame forward or backward through a circuit. The methods apply_pf and apply_pf_back are used to propagate the PauliFrame forward and backward respectively.
The Instruction class is an abstract class and should not be instantiated directly.
- Raises:
NotImplementedError – If the method is not implemented in the subclass.
- abstractmethod apply(input_tableau)[source]
Abstract method that applies the quantum operation to the input Tableau.
- class loom.cliffordsim.moments.instruction.InstructionDecorator(instruction, input_operation)[source]
Bases:
InstructionAn InstructionDecorator is a wrapper around an Instruction that adds additional functionality to the Instruction. The wrapped Instruction is then used to apply quantum operations to a Tableau, or PauliFrame, representation of a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.base_operation.Operation) – The Operation that will be applied.
- wrapped_instruction
The Instruction that is being decorated.
- Type:
- input_operation
The quantum operation that is being applied to the quantum state.
- apply(input_tableau, data_store, **kwargs)[source]
Applies the quantum operation to the input Tableau.
- apply_pf(input_pauliframes, data_store, **kwargs)[source]
Applies the quantum operation to the input PauliFrames.
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- apply_pf_back(input_pauliframes, data_store, **kwargs)[source]
Applies the quantum operation to the input PauliFrames. (For backward propagation.)
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- abstractmethod extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- abstractmethod extra_pf(input_pauliframes, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply_pf method.
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- abstractmethod extra_pf_back(input_pauliframes, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply_pf_back method.
- Return type:
Tuple[List[PauliFrame],DataStore,Dict]
- class loom.cliffordsim.moments.instruction.MeasurementDecorator(instruction, input_operation)[source]
Bases:
ClassicalBitDecoratorThe MeasurementDecorator applies a measurement operation to a qubit in a quantum state. It also records the measurement result in a classical register if it exists.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.MeasurementOperation) – The measurement operation that will be applied.
- qubit
The qubit to be measured.
- Type:
int
- measurement_id
The label of the measurement operation.
- Type:
str
- bias
The bias of the measurement result.
- Type:
float
- reg_name
The name of the classical register where the measurement result will be stored.
- Type:
str
- bit_order
The order of the bit in the classical register.
- Type:
int
- bit_id
The ID of the bit in the classical register.
- Type:
int
- static apply_meas_pf(input_pauliframes, qubit, basis)[source]
Applies a measurement operation to a list of PauliFrames and returns the modified PauliFrames along with the measurement results.
- Return type:
tuple[List[PauliFrame],List[int]]
- static deduce_mresult_deterministic(input_tableau, m_qubit)[source]
Performs measurement operation and returns the result.
- Parameters:
input_tableau (Tableau) – The input tableau of the quantum state.
m_qubit (int) – Qubit to be measured
- Returns:
Result of the measurement operation.
- Return type:
Literal[0, 1]
- static deduce_mresult_probabilistic(input_tableau, m_qubit, p, bias=0.5)[source]
Performs measurement operation and returns the result for a random measurement.
- Parameters:
input_tableau (Tableau) – The input tableau of the quantum state.
m_qubit (int) – Qubit to be measured
p (int) – Pivot index
bias (float, optional) – The bias of the result, by default 0.5 If this is set to 0 then the result will always be 0.
- Returns:
Result of the measurement operation.
- Return type:
Literal[0, 1]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- extra_pf(input_pauliframes, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply_pf method.
- extra_pf_back(input_pauliframes, data_store, **kwargs)[source]
Note that changes that causes the pauliframes to interact with Datastore when propagating forward, are not properly implemented here for the backward pass. Basically ignore the problem until we have a better solution.
- static find_pivot(input_tableau, m_qubit)[source]
Finds the pivot point for the measurement operation.
- Parameters:
input_tableau (Tableau) – The input tableau of the quantum state.
m_qubit (int) – Qubit to be measured
- Returns:
Pivot index
- Return type:
int
- static is_result_random(input_tableau, m_qubit, p)[source]
Checks if the measurement of a qubit, will result in a random outcome. The pivot point has to also be given.
- Parameters:
input_tableau (Tableau) – The input tableau of the quantum state.
m_qubit (int) – Qubit to be measured
p (int) – Pivot index
- Returns:
Whether the result will be random or not.
- Return type:
bool
- classmethod measure(input_tableau, m_qubit, bias=0.5)[source]
Determines the measurement result of a qubit and whether it is random. It also updates the input tableau if the measurement result is random.
- Parameters:
input_tableau (Tableau) – The input tableau of the quantum state.
m_qubit (int) – The qubit to be measured.
bias (float, optional) – The bias of the result, by default 0.5
- Returns:
A tuple containing whether the measurement result is random and what its value is.
- Return type:
tuple[bool, int]
- class loom.cliffordsim.moments.instruction.PhaseDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe PhaseDecorator applies a phase gate, Z(+pi/2), to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Phase) – The Phase Operation that will be applied.
- qubit
The qubit to apply the phase gate to.
- Type:
int
- static apply_phase(input_tableau, qubit)[source]
Applies a phase gate on a specific qubit.
- Parameters:
input_tableau (Tableau) – The input representation of the quantum state.
qubit (int) – The qubit to apply the phase gate to.
- static apply_phase_pf(input_pauliframes, qubit)[source]
Applies a phase gate on a specific qubit in a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.PhaseInvDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe PhaseInvDecorator applies the inverse of a phase gate, Z(-pi/2), to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.PhaseInv) – The PhaseInv Operation that will be applied.
- qubit
The qubit to apply the inverse of the phase gate to.
- Type:
int
- static apply_phase_inv(input_tableau, qubit)[source]
Applies the inverse of a phase gate on a specific qubit.
- Parameters:
input_tableau (Tableau) – The input representation of the quantum state.
qubit (int) – The qubit to apply the inverse of the phase gate to.
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.RecordClassicalRegisterDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe RecordClassicalRegisterDecorator records the state of a classical register in the DataStore. The classical register must exist in the registry in the Engine at runtime.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (RecordClassicalRegister) – The RecordClassicalRegister Operation that will be applied.
- reg_name
The name of the classical register.
- Type:
str
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.RecordPauliFrameDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe RecordPauliFrameDecorator records the state of a PauliFrame object in the DataStore. The PauliFrame object must be in the list of propagating PauliFrames at runtime.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (RecordPauliFrame) – The RecordPauliFrame Operation that will be applied.
- pauli_frame
The PauliFrame object to be recorded.
- Type:
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ResetDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe ResetDecorator applies a reset operation to a qubit in a quantum state. The qubit is first measured, if the measurement result of the qubit is 1, an X gate will be applied to the qubit to reset it to 0.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Reset) – The Reset Operation that will be applied.
- qubit
The qubit to be reset.
- Type:
int
- static apply_reset_pf(input_pauliframes, qubit)[source]
A staticmethod that applies a Reset operation to a list of PauliFrames
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.SWAPDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe SWAPDecorator applies a SWAP gate across 2 qubits, labelled as control qubit and target qubit.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.SWAP) – The SWAP Operation that will be applied.
- c_qubit
The qubit that will have its state “swapped” with the target qubit.
- Type:
int
- t_qubit
The qubit that will have its state “swapped” with the control qubit.
- Type:
int
- static apply_swap_pf(input_pauliframes, c_qubit, t_qubit)[source]
A staticmethod that applies a SWAP gate to a list of PauliFrames.
- Return type:
List[PauliFrame]
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.UpdateTableauDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe UpdateTableauDecorator updates the tableau of the quantum state with a new tableau. The new tableau must be a numpy ndarray. The decorator can also validate the tableau before updating.
The new tableau must be of the same shape as the current tableau. (Ignoring the scratch row)
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (UpdateTableau) – The UpdateTableau Operation that will be applied.
- tableau
The new tableau to be updated.
- Type:
np.ndarray
- validate
A flag to validate the tableau before updating.
- Type:
bool
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.XDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe XDecorator applies an X gate to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.X) – The X Operation that will be applied.
- qubit
The qubit to apply the X gate to.
- Type:
int
- static apply_x(input_tableau, qubit)[source]
Applies an X gate on a specific qubit.
- Parameters:
input_tableau (Tableau) – The input representation of the quantum state.
qubit (int) – The qubit to apply the X gate to.
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.YDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe YDecorator applies a Y gate to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Y) – The Y Operation that will be applied.
- qubit
The qubit to apply the Y gate to.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.
- class loom.cliffordsim.moments.instruction.ZDecorator(instruction, input_operation)[source]
Bases:
InstructionDecoratorThe ZDecorator applies a Z gate to a qubit in a quantum state.
- Parameters:
instruction (Instruction) – The instruction that is being decorated.
input_operation (
loom.cliffordsim.operations.Z) – The Z Operation that will be applied.
- qubit
The qubit to apply the Z gate to.
- Type:
int
- extra(input_tableau, data_store, **kwargs)[source]
An abstract method that adds additional functionality to the apply method.