Skip to content

Commit a6f9f1e

Browse files
committed
gates controlled on state 0
1 parent b5d1443 commit a6f9f1e

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/qrisp/interface/converter/cirq_converter.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"cx": CNOT,
2929
"cz": CZ,
3030
"swap": SWAP,
31-
"2cx": CCNOT,
3231
"h": H,
3332
"x": X,
3433
"y": Y,
@@ -63,11 +62,6 @@ def convert_to_cirq(qrisp_circuit):
6362
qrisp_circ_num_qubits = qrisp_circuit.num_qubits()
6463
qrisp_circ_ops_data = qrisp_circuit.data
6564

66-
# create generic 'ncx' keys in qrisp_cirq_ops_dict for the possibility of multicontrolled cx gates
67-
for n in range(3, qrisp_circ_num_qubits + 1):
68-
# start at 3 because 2cx is a Toffoli gate which already exists in Cirq
69-
qrisp_cirq_ops_dict[f"{n}cx"] = None
70-
7165
# create an empty Cirq circuit
7266
cirq_circuit = Circuit()
7367
cirq_qubits = [LineQubit(i) for i in range(qrisp_circ_num_qubits)]
@@ -88,6 +82,8 @@ def convert_to_cirq(qrisp_circuit):
8882

8983
if op_i not in qrisp_cirq_ops_dict:
9084
try:
85+
# this code block also ends up transpiling a mcx gate
86+
# qrisp allows for different types of control state but cirq does not
9187
def transpile_predicate(op):
9288
if op.name == op_i:
9389
return True
@@ -111,7 +107,6 @@ def transpile_predicate(op):
111107
"cx",
112108
"cz",
113109
"swap",
114-
"2cx",
115110
"h",
116111
"x",
117112
"y",
@@ -130,10 +125,6 @@ def transpile_predicate(op):
130125
"sx",
131126
"sx_dg",
132127
]
133-
# create generic 'ncx' keys in the cirq gates filter for the possibility of multicontrolled cx gates
134-
for n in range(3, qrisp_circ_num_qubits + 1):
135-
# start at 3 because 2cx is a Toffoli gate which already exists in Cirq
136-
cirq_gates_filter.append(f"{n}cx")
137128

138129
if (op_i not in cirq_gates_filter) and instr.op.definition:
139130
new_circ = instr.op.definition

tests/interface_tests/test_cirq_converter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def ghz(qv):
124124

125125
reflection_compiled_qc = qv.qs.compile()
126126
reflection_cirq_qc = convert_to_cirq(reflection_compiled_qc)
127+
128+
expected_unitary = reflection_compiled_qc.get_unitary()
129+
# multiple by -1 to account for the global phase factor
130+
calculated_unitary = -1*unitary(reflection_cirq_qc)
131+
np.testing.assert_array_almost_equal(expected_unitary, calculated_unitary)
127132

128133

129134
def test_transpiled_qc():

0 commit comments

Comments
 (0)