The Steane Module¶
The Steane Module implements Quantum Error Correction and Quantum Fault Tolerance using the Steane 7-qubit code. The 7-qubit code encodes the state \(|\phi\rangle\) as
-
class
Steane.
SteaneEncoder
[source]¶ Bases:
BaseFaultTolerance.Encoder
A class for implementing non-fault tolerant preparation of the Steane \(|0\rangle\) state. As described at the top of this page, the \(|0\rangle\) state is encoded as
\[|\tilde{0}\rangle = (1+X_0X_4X_5X_6)(1+X_1X_3X_5X_6)(1+X_2X_3X_4X_6)|0\rangle.\]The circuit representation of the initialization process is:Methods
createEncoderCircuit :
Creates a circuit encoding the \(|0\rangle\) state
createEncoderDag :
Creates a DAG encoding the \(|0\rangle\) state
getEncoderCircuit :
Adds gates encoding the \(|0\rangle\) state to a circuit
getEncoderDag :
Adds gates encoding the \(|0\rangle\) state to a DAG
-
createEncoderCircuit
(numQubits)¶ Creates a circuit encoding the specified number of qubits to the encoded \(|0\rangle\) state.
- Parameters
- numQubitsint
The number of qubits to initialize to the encoded \(|0\rangle\) state.
-
createEncoderDag
(numQubits)¶ Creates a DAG encoding the specified number of qubits to the encoded \(|0\rangle\) state.
- Parameters
- numQubitsint
The number of qubits to initialize to the encoded \(|0\rangle\) state.
-
getEncoderCircuit
(circuit, qregs, cregs=None, ancillas=None)¶ Encodes the specified Quantum Registers to the encoded \(|0\rangle\) state for the given circuit.
- Parameters
- dagDAGCircuit
The circuit for which to create the encoding.
- qregslist(QuantumRegister)
The Quantum Registers to encode to the \(|0\rangle\).
- cregslist(ClassicalRegister), Optional
The Classical Registers used to encode to the \(|0\rangle\), if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to encode to the \(|0\rangle\), if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-
getEncoderDag
(dag, qregs, cregs=None, ancillas=None)¶ Encodes the specified Quantum Registers to the encoded \(|0\rangle\) state for the given DAG.
- Parameters
- dagDAGCircuit
The circuit for which to create the encoding.
- qregslist(QuantumRegister)
The Quantum Registers to encode to the \(|0\rangle\).
- cregslist(ClassicalRegister), Optional
The Classical Registers used to encode to the \(|0\rangle\), if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to encode to the \(|0\rangle\), if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-
-
class
Steane.
SteaneErrorCorrector
[source]¶ Bases:
BaseFaultTolerance.ErrorCorrector
A class for implementing non-fault tolerant error correction for the Steane Code. This class combines
SteaneSyndromeDetection
andSteaneSyndromeCorrection
into a single class for ease of use.Methods
errorCorrectCircuit :
Implements error correction for the given circuit.
errorCorrecDag :
Implements error correction for the given DAG.
-
errorCorrectCircuit
(circuit, qregs, cregs=None, ancillas=None)¶ Creates gates implementing fault tolerant error correction for the given qubits in the given circuit.
- Parameters
- circuitQuantumCircuit
The circuit for which to perform error correction.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform error correction.
- cregslist(ClassicalRegister)
The Classical Registers used to perform error correction, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome correction process for theqregs[i]
quantum register will use thecregs[i]
classical register.
-
errorCorrectDag
(dag, qregs, cregs=None, ancillas=None)¶ Creates gates implementing non-fault tolerant error correction for the given qubits in the given DAG.
- Parameters
- dagDAGCircuit
The dag for which to perform error correction.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform error correction.
- cregslist(ClassicalRegister)
The Classical Registers used to perform error correction, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome correction process for theqregs[i]
quantum register will use thecregs[i]
classical register.
-
-
class
Steane.
SteaneFaultTolerantEncoder
(numRepeats)[source]¶ Bases:
BaseFaultTolerance.FaultTolerantEncoder
A class for implementing fault tolerant ecoding of the Steane encoded \(|0\rangle\) state. NOT FINISHED.
- Parameters
- numRepeatsint
The number of times to try to create the \(|0\rangle\) state before giving up.
Methods
createEncoderCircuit :
Creates a circuit encoding the \(|0\rangle\) state
createEncoderDag :
Creates a DAG encoding the \(|0\rangle\) state
getEncoderCircuit :
Adds gates encoding the \(|0\rangle\) state to a circuit
getEncoderDag :
Adds gates encoding the \(|0\rangle\) state to a DAG
-
createEncoderCircuit
(numQubits)¶ Creates a circuit fault-tolerantly encoding the specified number of qubits to the encoded \(|0\rangle\) state.
- Parameters
- numQubitsint
The number of qubits to initialize to the encoded \(|0\rangle\) state.
-
createEncoderDag
(numQubits)¶ Creates a DAG fault-tolerantly encoding the specified number of qubits to the encoded \(|0\rangle\) state.
- Parameters
- numQubitsint
The number of qubits to initialize to the encoded \(|0\rangle\) state.
-
getEncoderCircuit
(circuit, qregs, cregs1=None, ancillas1=None, cregs2=None, ancillas2=None)¶ Fault-tolerantly encodes the specified Quantum Registers to the encoded \(|0\rangle\) state for the given circuit.
- Parameters
- dagDAGCircuit
The circuit for which to create the encoding.
- qregslist(QuantumRegister)
The Quantum Registers to encode to the \(|0\rangle\).
- cregslist(ClassicalRegister), Optional
The Classical Registers used to encode to the \(|0\rangle\), if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to encode to the \(|0\rangle\), if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-
getEncoderDag
(dag, qregs, cregs1=None, ancillas1=None, cregs2=None, ancillas2=None)¶ Fault-tolerantly encodes the specified Quantum Registers to the encoded \(|0\rangle\) state for the given DAG.
- Parameters
- dagDAGCircuit
The circuit for which to create the encoding.
- qregslist(QuantumRegister)
The Quantum Registers to encode to the \(|0\rangle\).
- cregslist(ClassicalRegister), Optional
The Classical Registers used to encode to the \(|0\rangle\), if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to encode to the \(|0\rangle\), if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the encoding process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-
class
Steane.
SteaneFaultTolerantGates
[source]¶ Bases:
BaseFaultTolerance.FaultTolerantGates
A class for implementing fault tolerant gates for the Steane Code. The current implemented gates are \(X,\) \(H,\) \(S,\) and CNOT. These gates can all be implemented bitwise. The figures below show the implementations for these four gates.
Methods
addGateCircuit :
Adds a fault tolerant gate to the given circuit.
addGateDag :
Adds a fault tolerant gate to the given DAG.
-
addGateCircuit
(circuit, gate, qregs, cregs=None, ancillas=None)¶ Adds the specified number of fault tolerant implementations of a quantum gate to the given circuit.
- Parameters
- circuitQuantumCircuit
The circuit on which to perform the fault tolerant gate.
- gateGate
The non-fault tolerant gate for which to implement a fault tolerant version.
- qregslist(list(QuantumRegister))
The Quantum Registers to on which to perform the fault tolerant gate. Each
qregs[i]
represents the list of quantum registers which correspond to the ith input to the non-fault tolerant version of the gate in question. Note that eachqregs[i]
must have the same length.- cregslist(list(ClassicalRegister)), Optional
The Classical Registers used to perform syndrome detection, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs[0])
and the syndrome detection process for theqregs[i][j]
quantum register will use thecregs[j]
classical register.- ancillaslist(list(AncillaRegister)), list(list(QuantumRegister)), Optional
The Ancilla Registers used to perform syndrome detection,, if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(qregs[0])
and the syndrome detection process for theqregs[i][j]
quantum register will use theancillas[j]
ancilla register.
-
addGateDag
(dag, gate, qregs, cregs=None, ancillas=None)¶ Adds the specified number of fault tolerant implementations of a quantum gate to the given DAG.
- Parameters
- dagDAGCircuit
The dag on which to perform the fault tolerant gate.
- gateGate
The non-fault tolerant gate for which to implement a fault tolerant version.
- qregslist(list(QuantumRegister))
The Quantum Registers to on which to perform the fault tolerant gate. Each
qregs[i]
represents the list of quantum registers which correspond to the ith input to the non-fault tolerant version of the gate in question. Note that eachqregs[i]
must have the same length.- cregslist(list(ClassicalRegister)), Optional
The Classical Registers used to perform syndrome detection, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs[0])
and the syndrome detection process for theqregs[i][j]
quantum register will use thecregs[j]
classical register.- ancillaslist(list(AncillaRegister)), list(list(QuantumRegister)), Optional
The Ancilla Registers used to perform syndrome detection,, if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(qregs[0])
and the syndrome detection process for theqregs[i][j]
quantum register will use theancillas[j]
ancilla register.
-
-
class
Steane.
SteaneSyndromeCorrector
[source]¶ Bases:
BaseFaultTolerance.SyndromeCorrector
A class for implementing fault tolerant syndrome correction for the Steane code. The circuit representation for Syndrome Correction is shown below:
Methods
syndromeCorrectCircuit :
Implements syndrome correction for the given circuit.
syndromeCorrectDag :
Implements syndrome correction for the given DAG.
-
syndromeCorrectCircuit
(circuit, qregs, cregs)¶ Creates gates implementing fault tolerant syndrome correction for the given qubits in the given circuit.
- Parameters
- circuitQuantumCircuit
The circuit for which to perform syndrome correction.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform syndrome correction.
- cregslist(ClassicalRegister)
The Classical Registers used to perform syndrome correction, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome correction process for theqregs[i]
quantum register will use thecregs[i]
classical register.
-
syndromeCorrectDag
(dag, qregs, cregs)¶ Creates gates implementing fault tolerant syndrome correction for the given qubits in the given DAG.
- Parameters
- dagDAGCircuit
The dag for which to perform syndrome correction.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform syndrome correction.
- cregslist(ClassicalRegister)
The Classical Registers used to perform syndrome correction, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome correction process for theqregs[i]
quantum register will use thecregs[i]
classical register.
-
-
class
Steane.
SteaneSyndromeDetector
[source]¶ Bases:
BaseFaultTolerance.SyndromeDetector
A class for implementing non-fault tolerant syndrome detection for the Steane Code. Syndrome detection works by measuring six stabilizer operators, \(M_a,\) \(M_b,\) \(M_c,\) \(N_a,\) \(N_b,\) and \(N_c,\) defined at the top of this page. The circuit representation of the syndrome detection process is:
Methods
syndromeDetectCircuit :
Implements syndrome detection for the given circuit.
syndromeDetectDag :
Implements syndrome detection for the given DAG.
-
syndromeDetectCircuit
(circuit, qregs, cregs=None, ancillas=None)¶ Creates gates implementing non-fault tolerant syndrome detection for the given qubits in the given circuit.
- Parameters
- circuitQuantumCircuit
The circuit for which to perform syndrome detection.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform syndrome detection.
- cregslist(ClassicalRegister), Optional
The Classical Registers used to perform syndrome detection, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome detection process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to perform syndrome detection,, if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the syndrome detection process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-
syndromeDetectDag
(dag, qregs, cregs=None, ancillas=None)¶ Creates gates implementing non-fault tolerant syndrome detection for the given qubits in the given DAG.
- Parameters
- dagDAGCircuit
The DAG for which to perform syndrome detection.
- qregslist(QuantumRegister)
The Quantum Registers to on which to perform syndrome detection.
- cregslist(ClassicalRegister), Optional
The Classical Registers used to perform syndrome detection, if classical registers are needed. If
cregs
is provided, it must satisfylen(cregs) == len(qregs)
and the syndrome detection process for theqregs[i]
quantum register will use thecregs[i]
classical register.- ancillaslist(AncillaRegister), list(QuantumRegister), Optional
The Ancilla Registers used to perform syndrome detection,, if ancilla registers are needed. If
ancillas
is provided, it must satisfylen(ancillas) == len(cregs) == len(qregs)
and the syndrome detection process for theqregs[i]
quantum register will use theancillas[i]
ancilla register.
-