@@ -642,56 +642,55 @@ def propagate(control_in: str, target_in: str):
642642
643643def apply_qasm_pauli_gate (qreg_name : str , qubit : int , pauli_gates : str ):
644644 """
645-
645+ Construct an OpenQASM-string line with the given Pauli-gates applid to the given qubit.
646646
647647 Parameters
648648 ----------
649649 qreg_name :str
650+ The name of the qiskit.QuantumRegister containing the qubit.
650651 qubit : int
652+ The index of the qubit.
651653 pauli_gates : str
652-
654+ A string determining the Pauli-gates to be applied. Must be a sequence the characters I, X, Y and/or Z.
653655 Returns
654656 -------
655-
656- """
657-
658- """
659- Construct a OpenQASM-string with the instruction to apply the given pauli gates to
660- the given qubit
661-
662- :param qreg_name: Name of quantum register
663- :param qubit: Index of qubit
664- :param pauli_gates: The Pauli gates to be applied
665- :return: The OpenQASM-string with the instruction
657+ new_qasm_line : str
658+ An OpenQASM string with the Pauli-gates applied to the qubit.
666659 """
667660 new_qasm_line = ''
668661 for gate in pauli_gates :
669662 if gate != 'I' :
663+ if gate not in PHYSICAL_GATE_CONVERSION .keys ():
664+ raise Exception ("Invalid Pauli-gate used in Pauli-twirl: {:}" .format (gate ))
670665 u_gate = PHYSICAL_GATE_CONVERSION [gate ]
671666 new_qasm_line += u_gate + ' ' + qreg_name + '[' + str (qubit ) + '];' + '\n '
672667 return new_qasm_line
673668
674669
675670def pauli_twirl_cnot_gate (qreg_name : str , qasm_line_cnot : str ) -> str :
676671 """
672+ Pauli-twirl a specific CNOT-gate. This involves drawing two random Pauli-gates a and b, picked from the single-qubit
673+ Pauli set {Id, X, Y, Z}, then determining the corresponding two Pauli-gates c and d such that
674+ (a x b) * CNOT * (c x d) = CNOT, for an ideal CNOT.
675+
676+ The original CNOT gates is then replaced by the gate ((a x b) * CNOT * (c x d)). This transforms the noise in the
677+ CNOT-gate into stochastic Pauli-type noise. An underlying assumption is that the noise in the single-qubit Pauli
678+ gates is negligible to the noise in the CNOT-gates.
677679
678680 Parameters
679681 ----------
680- qreg_name
681- qasm_line_cnot
682+ qreg_name : str
683+ The name of the qiskit.QuantumRegister for the qubits in question.
684+ qasm_line_cnot : str
685+ The OpenQASM-string line containing the CNOT-gate.
682686
683687 Returns
684688 -------
685-
686- """
689+ new_qasm_line : str
690+ A new OpenQASM-string section to replace the aforementioned OpenQASM line containing the CNOT-gate, where not
691+ the CNOT-gate has been Pauli-twirled.
687692 """
688- Pauli-twirl a CNOT-gate from the given OpenQASM string line containing the CNOT.
689- This will look something like: cx q[0],q[1];
690693
691- :param qreg_name: Name of quantum register
692- :param qasm_line_cnot: OpenQASM-line containing the CNOT to pauli twirl
693- :return:
694- """
695694 control , target = find_cnot_control_and_target (qasm_line_cnot )
696695
697696 # Note: XZ = -i*Y, with inverse (XZ)^-1 = ZX = i*Y. This simplifies the propagation of gates a,b over the CNOT
@@ -717,21 +716,18 @@ def pauli_twirl_cnot_gate(qreg_name: str, qasm_line_cnot: str) -> str:
717716
718717def pauli_twirl_cnots (qc : QuantumCircuit ) -> QuantumCircuit :
719718 """
719+ Pauli-twirl all CNOT-gates in a general quantum circuit. This function is included here for completeness.
720+
720721
721722 Parameters
722723 ----------
723- qc
724+ qc : qiskit.QuantumCircuit
725+ The original quantum circuit.
724726
725727 Returns
726728 -------
727-
728- """
729- """
730- General function for Pauli-twirling all CNOT-gates in a quantum circuit.
731- Included for completeness.
732-
733- :param qc: quantum circuit for which to Pauli twirl all CNOT gates
734- :return: Pauli twirled quantum circuit
729+ pauli_twirled_qc : qiskit.QuantumCircuit
730+ The quantum circuit where all CNOT-gates have been Pauli-twirled.
735731 """
736732
737733 # The circuit may be expressed in terms of various types of gates.
0 commit comments