From cb5732c43cff98a42b407919bd5e7c8950a24732 Mon Sep 17 00:00:00 2001 From: Callum Macpherson <93673602+CalMacCQ@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:55:11 +0100 Subject: [PATCH] fix: failing resynth test case (#10) * add test case back in * fix cnot synthesis * remove import --- src/topt_proto/clifford.py | 9 +++------ tests/qasm/cnot_t_4.qasm | 13 +++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 tests/qasm/cnot_t_4.qasm diff --git a/src/topt_proto/clifford.py b/src/topt_proto/clifford.py index 4391e1d..c1e61da 100644 --- a/src/topt_proto/clifford.py +++ b/src/topt_proto/clifford.py @@ -32,11 +32,8 @@ def pauli_tensor_to_circuit(pauli_tensor: QubitPauliTensor) -> Circuit: def get_cnot_circuit(pbox: PhasePolyBox) -> Circuit: """Generate a CNOT circuit implementing the linear reversible circuit L.""" # cheat by synthesising the CNOT circuit with qiskit and converting - qc = synth_cnot_count_full_pmh( - pbox.linear_transformation, section_size=2 - ) # correct for endianness - qc2 = qc.reverse_bits() - tkc_cnot: Circuit = qiskit_to_tk(qc2) + qc = synth_cnot_count_full_pmh(pbox.linear_transformation, section_size=2) + tkc_cnot: Circuit = qiskit_to_tk(qc) return tkc_cnot @@ -46,7 +43,7 @@ def get_pauli_conjugate( ) -> QubitPauliTensor: """Given a PhasePolyBox (U) and a QubitPauliTensor (P), returns P' = L P L†.""" - l_cnot_circuit: Circuit = get_cnot_circuit(pbox=pbox) + l_cnot_circuit: Circuit = get_cnot_circuit(pbox=pbox).dagger() # Get L as a Tableau l_tableau = UnitaryTableau(l_cnot_circuit) diff --git a/tests/qasm/cnot_t_4.qasm b/tests/qasm/cnot_t_4.qasm new file mode 100644 index 0000000..98883be --- /dev/null +++ b/tests/qasm/cnot_t_4.qasm @@ -0,0 +1,13 @@ +OPENQASM 2.0; +include "qelib1.inc"; + +qreg q[3]; +cx q[2],q[0]; +rz(0.25*pi) q[0]; +cx q[1],q[0]; +cx q[2],q[0]; +rz(0.25*pi) q[0]; +cx q[1],q[0]; +cx q[0],q[1]; +cx q[1],q[0]; +rz(0.25*pi) q[1]; \ No newline at end of file