Skip to content

Commit

Permalink
fix: failing resynth test case (#10)
Browse files Browse the repository at this point in the history
* add test case back in

* fix cnot synthesis

* remove import
  • Loading branch information
CalMacCQ authored Oct 12, 2024
1 parent b9daf2f commit cb5732c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/topt_proto/clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/qasm/cnot_t_4.qasm
Original file line number Diff line number Diff line change
@@ -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];

0 comments on commit cb5732c

Please sign in to comment.