diff --git a/AUTHORS b/AUTHORS index d253a68a5b..b796b2cdd0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -59,3 +59,4 @@ Vladimir Kozhukalov Francesc Sabater Emiliano Godinez Tommy Nguyen +Duong H. D. Tran \ No newline at end of file diff --git a/mitiq/interface/mitiq_qiskit/conversions.py b/mitiq/interface/mitiq_qiskit/conversions.py index 72fb4c94fb..77d62e2e8b 100644 --- a/mitiq/interface/mitiq_qiskit/conversions.py +++ b/mitiq/interface/mitiq_qiskit/conversions.py @@ -249,14 +249,17 @@ def from_qiskit(circuit: qiskit.QuantumCircuit) -> cirq.Circuit: Returns: Mitiq circuit representation equivalent to the input Qiskit circuit. """ + try: mitiq_circuit = from_qasm(qasm2.dumps(circuit)) except QasmException: # Try to decompose circuit before running # This is necessary for converting qiskit circuits with # custom packaged gates, e.g., QFT gates - circuit = circuit.decompose() + GATES_TO_DECOMPOSE = ["rxx", "rzz", "rzx", "ryy", "QFT"] + circuit = circuit.decompose(gates_to_decompose=GATES_TO_DECOMPOSE) mitiq_circuit = from_qasm(qasm2.dumps(circuit)) + return mitiq_circuit diff --git a/mitiq/interface/mitiq_qiskit/tests/test_conversions_qiskit.py b/mitiq/interface/mitiq_qiskit/tests/test_conversions_qiskit.py index 4ceb8d5d4d..52d146cf32 100644 --- a/mitiq/interface/mitiq_qiskit/tests/test_conversions_qiskit.py +++ b/mitiq/interface/mitiq_qiskit/tests/test_conversions_qiskit.py @@ -476,3 +476,11 @@ def test_remove_identity_from_idle_with_multiple_registers(): input_multi, input_single = _multi_reg_circuits() assert circuit_multi_reg == input_multi assert circuit_single_reg == input_single + + +def test_convert_to_mitiq_with_rx_and_rzz(): + """Tests that convert_to_mitiq works with RX and RZZ gates.""" + test_qc = qiskit.QuantumCircuit(2) + test_qc.rx(0.1, 0) + test_qc.rzz(0.1, 0, 1) + assert convert_to_mitiq(test_qc)