scalerqec.QEC package¶
Submodules¶
scalerqec.QEC.magic module¶
scalerqec.QEC.noisemodel module¶
- class scalerqec.QEC.noisemodel.ErrorType(value)[source]¶
Bases:
Enum- CNOT = 2¶
- CZ = 8¶
- HADAMARD = 3¶
- MEASUREMENT = 0¶
- PAULIX = 5¶
- PAULIY = 6¶
- PAULIZ = 7¶
- PHASE = 4¶
- RESET = 1¶
- class scalerqec.QEC.noisemodel.NoiseModel(error_rate: float)[source]¶
Bases:
objectA class representing a noise model for quantum error correction simulations.
- disable_error(error_type: str) None[source]¶
Disable a specific type of error in the noise model.
- Parameters:
error_type – The type of error to disable.
- property error_rate: float¶
Get the error rate of the noise model.
- Returns:
The error rate as a float.
- reconstruct_clifford_circuit(clifford_circuit: CliffordCircuit) CliffordCircuit[source]¶
Reconstruct a given Clifford circuit to incorporate the noise model.
- Parameters:
clifford_circuit – The original Clifford circuit to be modified.
- Returns:
A new Clifford circuit with the noise model applied.
- rewrite_stim_program(stim_program) str[source]¶
Rewrite a given stim program to incorporate the noise model.
- Parameters:
stim_program – The original stim program to be modified.
- Returns:
A new stim program with the noise model applied.
- uniform_depolarization_single() str[source]¶
Apply uniform depolarization noise to single-qubit operations in the stim program.
- Parameters:
stim_program (str) – The original stim program.
- Returns:
The modified stim program with depolarization noise applied.
- Return type:
str
# Placeholder for actual implementation
scalerqec.QEC.qeccircuit module¶
- class scalerqec.QEC.qeccircuit.DetectorInstruction(dest: str, args: list[str])[source]¶
Bases:
ParityInstructionA class representing a detector instruction in the intermediate representation (IR) of a quantum circuit.
- class scalerqec.QEC.qeccircuit.IF_THENInstruction(condition: str, then_branch: list[IRInstruction])[source]¶
Bases:
IRInstructionA class representing an IF-THEN instruction in the intermediate representation (IR) of a quantum circuit.
- class scalerqec.QEC.qeccircuit.IRInstruction(instr_type)[source]¶
Bases:
objectA class representing an intermediate representation (IR) instruction for quantum circuits.
- class scalerqec.QEC.qeccircuit.IRType(value)[source]¶
Bases:
Enum- DETECTOR = 1¶
- IF_THEN = 3¶
- OBSERVABLE = 2¶
- PROP = 0¶
- REPEAT = 6¶
- REPEAT_UNTIL = 5¶
- WHILE = 4¶
- class scalerqec.QEC.qeccircuit.ObservableInstruction(dest: str, args: list[str])[source]¶
Bases:
ParityInstructionA class representing an observable instruction in the intermediate representation (IR) of a quantum circuit.
- class scalerqec.QEC.qeccircuit.ParityInstruction(ir_type: IRType, dest: str, args: list[str])[source]¶
Bases:
IRInstructionBase class for parity-based IR instructions (detectors, observables).
- property args: list[str]¶
- property dest: str¶
- class scalerqec.QEC.qeccircuit.StabCode(n: int, k: int, d: int)[source]¶
Bases:
objectA class representing a quantum error-correcting code (QECC) using the stabilizer formalism.
- add_stab(stab: str) None[source]¶
Add a stabilizer generator to the code.
- Parameters:
stab (str) – A string representation of the stabilizer generator.
- property circuit: None¶
Get the Clifford circuit for the quantum error-correcting code.
- Returns:
The Clifford circuit.
- compile_stim_circuit_from_IR_standard() None[source]¶
Compile the stim circuit from the intermediate representation (IR).
- Returns:
The compiled stim circuit as a string.
- Return type:
str
- construct_IR_standard_scheme()[source]¶
Construct the quantum error-correcting circuit using the standard scheme. Now, we will create the intermediate representation (IR) for the circuit.
- construct_circuit()[source]¶
Construct the quantum error-correcting circuit based on the stabilizers and scheme.
- There is a two step compilation:
First, compile the stabilizers into an intermediate representation (IR) of the circuit. Second, translate the IR into a Clifford circuit. In IR, there is no concept of qubits, only Pauli operators, detectors, observables, and their relationships.
The IR has the form:
c0 = Prop XYZIX c1 = Prop IXYZI d0 = Parity c0 c1 o0 = Parity c0
- construct_parity_check_matrix() None[source]¶
Construct the standard XZ parity check matrix for the quantum error-correcting code.
- Returns:
The parity check matrix.
- property d: int¶
Get the distance of the QECC.
- Returns:
The distance.
- Return type:
int
- get_parity_check_matrix() None[source]¶
Get the standard XZ parity check matrix for the quantum error-correcting code.
- Returns:
The parity check matrix.
- init_by_parity_check_matrix(paritymatrix: ndarray) None[source]¶
Initialize the QECC stabilizer structures using a given parity check matrix.
- Parameters:
paritymatrix (np.ndarray) – The parity check matrix.
- is_IR_compiled() bool[source]¶
Check if the intermediate representation (IR) has been compiled.
- Returns:
True if the IR is compiled, False otherwise.
- Return type:
bool
- is_circuit_compiled() bool[source]¶
Check if the quantum error-correcting circuit has been compiled.
- Returns:
True if the circuit is compiled, False otherwise.
- Return type:
bool
- property k: int¶
Get the number of logical qubits in the QECC.
- Returns:
The number of logical qubits.
- Return type:
int
- property n: int¶
Get the number of physical qubits in the QECC.
- Returns:
The number of physical qubits.
- Return type:
int
- property noisemodel: NoiseModel¶
Get the noise model associated with the QECC.
- Returns:
The noise model.
- Return type:
- property rounds: int¶
Get the number of error correction rounds.
- Returns:
The number of rounds.
- Return type:
int
- property scheme: SCHEME¶
Get the error correction scheme for the code.
- Returns:
The error correction scheme.
- Return type:
- set_logical_Z(index: int, logicalZ: str) None[source]¶
Set the logical Z operator for a given logical qubit.
- Parameters:
index (int) – The index of the logical qubit.
logicalZ (str) – A string representation of the logical Z operator.
- show_IR()[source]¶
Display the intermediate representation of the quantum error-correcting circuit.
The IR has the form:
- property stimcirc: None¶
Get the stimulus circuit for the quantum error-correcting code.
- Returns:
The stimulus circuit.
- class scalerqec.QEC.qeccircuit.REPEATInstruction(body: list[IRInstruction], times: int)[source]¶
Bases:
IRInstructionA class representing a REPEAT instruction in the intermediate representation (IR) of a quantum circuit.
- class scalerqec.QEC.qeccircuit.REPEAT_UNTILInstruction(body: list[IRInstruction], until_condition: str)[source]¶
Bases:
IRInstructionA class representing a REPEAT-UNTIL instruction in the intermediate representation (IR) of a quantum circuit.
- class scalerqec.QEC.qeccircuit.SCHEME(value)[source]¶
Bases:
Enum- FLAG = 3¶
- KNILL = 2¶
- SHOR = 1¶
- STANDARD = 0¶
- class scalerqec.QEC.qeccircuit.StabPropInstruction(round: int, stabindex: int, dest: str, stab: str, is_observable: bool = False, observable_index: int = -1)[source]¶
Bases:
IRInstructionA class representing an intermediate representation (IR) instruction for quantum circuits.
- property dest: str¶
Get the destination qubit/observable/detector from the instruction.
- Returns:
The destination string.
- Return type:
str
- get_observable_index() int[source]¶
Get the index of the observable if applicable.
- Returns:
The observable index.
- Return type:
int
- get_stabindex() int[source]¶
Get the stabilizer index of the stabilizer propagation.
- Returns:
The stabilizer index.
- Return type:
int
- is_observable() bool[source]¶
Check if the stabilizer propagation is for an observable.
- Returns:
True if it is an observable, False otherwise.
- Return type:
bool
- property round: int¶
Get the round number of the stabilizer propagation.
- Returns:
The round number.
- Return type:
int
- property stab: str¶
Get the stabilizer from the instruction.
- Returns:
The stabilizer string.
- Return type:
str
- class scalerqec.QEC.qeccircuit.WHILEInstruction(condition: str, body: list[IRInstruction])[source]¶
Bases:
IRInstructionA class representing a WHILE instruction in the intermediate representation (IR) of a quantum circuit.
scalerqec.QEC.small module¶
scalerqec.QEC.surface module¶
Module contents¶
- class scalerqec.QEC.NoiseModel(error_rate: float)[source]¶
Bases:
objectA class representing a noise model for quantum error correction simulations.
- disable_error(error_type: str) None[source]¶
Disable a specific type of error in the noise model.
- Parameters:
error_type – The type of error to disable.
- property error_rate: float¶
Get the error rate of the noise model.
- Returns:
The error rate as a float.
- reconstruct_clifford_circuit(clifford_circuit: CliffordCircuit) CliffordCircuit[source]¶
Reconstruct a given Clifford circuit to incorporate the noise model.
- Parameters:
clifford_circuit – The original Clifford circuit to be modified.
- Returns:
A new Clifford circuit with the noise model applied.
- rewrite_stim_program(stim_program) str[source]¶
Rewrite a given stim program to incorporate the noise model.
- Parameters:
stim_program – The original stim program to be modified.
- Returns:
A new stim program with the noise model applied.
- uniform_depolarization_single() str[source]¶
Apply uniform depolarization noise to single-qubit operations in the stim program.
- Parameters:
stim_program (str) – The original stim program.
- Returns:
The modified stim program with depolarization noise applied.
- Return type:
str
# Placeholder for actual implementation
- class scalerqec.QEC.StabCode(n: int, k: int, d: int)[source]¶
Bases:
objectA class representing a quantum error-correcting code (QECC) using the stabilizer formalism.
- add_stab(stab: str) None[source]¶
Add a stabilizer generator to the code.
- Parameters:
stab (str) – A string representation of the stabilizer generator.
- property circuit: None¶
Get the Clifford circuit for the quantum error-correcting code.
- Returns:
The Clifford circuit.
- compile_stim_circuit_from_IR_standard() None[source]¶
Compile the stim circuit from the intermediate representation (IR).
- Returns:
The compiled stim circuit as a string.
- Return type:
str
- construct_IR_standard_scheme()[source]¶
Construct the quantum error-correcting circuit using the standard scheme. Now, we will create the intermediate representation (IR) for the circuit.
- construct_circuit()[source]¶
Construct the quantum error-correcting circuit based on the stabilizers and scheme.
- There is a two step compilation:
First, compile the stabilizers into an intermediate representation (IR) of the circuit. Second, translate the IR into a Clifford circuit. In IR, there is no concept of qubits, only Pauli operators, detectors, observables, and their relationships.
The IR has the form:
c0 = Prop XYZIX c1 = Prop IXYZI d0 = Parity c0 c1 o0 = Parity c0
- construct_parity_check_matrix() None[source]¶
Construct the standard XZ parity check matrix for the quantum error-correcting code.
- Returns:
The parity check matrix.
- property d: int¶
Get the distance of the QECC.
- Returns:
The distance.
- Return type:
int
- get_parity_check_matrix() None[source]¶
Get the standard XZ parity check matrix for the quantum error-correcting code.
- Returns:
The parity check matrix.
- init_by_parity_check_matrix(paritymatrix: ndarray) None[source]¶
Initialize the QECC stabilizer structures using a given parity check matrix.
- Parameters:
paritymatrix (np.ndarray) – The parity check matrix.
- is_IR_compiled() bool[source]¶
Check if the intermediate representation (IR) has been compiled.
- Returns:
True if the IR is compiled, False otherwise.
- Return type:
bool
- is_circuit_compiled() bool[source]¶
Check if the quantum error-correcting circuit has been compiled.
- Returns:
True if the circuit is compiled, False otherwise.
- Return type:
bool
- property k: int¶
Get the number of logical qubits in the QECC.
- Returns:
The number of logical qubits.
- Return type:
int
- property n: int¶
Get the number of physical qubits in the QECC.
- Returns:
The number of physical qubits.
- Return type:
int
- property noisemodel: NoiseModel¶
Get the noise model associated with the QECC.
- Returns:
The noise model.
- Return type:
- property rounds: int¶
Get the number of error correction rounds.
- Returns:
The number of rounds.
- Return type:
int
- property scheme: SCHEME¶
Get the error correction scheme for the code.
- Returns:
The error correction scheme.
- Return type:
- set_logical_Z(index: int, logicalZ: str) None[source]¶
Set the logical Z operator for a given logical qubit.
- Parameters:
index (int) – The index of the logical qubit.
logicalZ (str) – A string representation of the logical Z operator.
- show_IR()[source]¶
Display the intermediate representation of the quantum error-correcting circuit.
The IR has the form:
- property stimcirc: None¶
Get the stimulus circuit for the quantum error-correcting code.
- Returns:
The stimulus circuit.