diff --git a/crates/accelerate/src/circuit_library/quantum_volume.rs b/crates/accelerate/src/circuit_library/quantum_volume.rs index e17357e7cec..a6c5a3839d9 100644 --- a/crates/accelerate/src/circuit_library/quantum_volume.rs +++ b/crates/accelerate/src/circuit_library/quantum_volume.rs @@ -27,7 +27,7 @@ use rayon::prelude::*; use qiskit_circuit::circuit_data::CircuitData; use qiskit_circuit::imports::UNITARY_GATE; use qiskit_circuit::operations::Param; -use qiskit_circuit::operations::PyInstruction; +use qiskit_circuit::operations::PyGate; use qiskit_circuit::packed_instruction::PackedOperation; use qiskit_circuit::{Clbit, Qubit}; use smallvec::{smallvec, SmallVec}; @@ -127,17 +127,16 @@ pub fn quantum_volume( let unitary_gate = UNITARY_GATE .get_bound(py) .call((unitary.clone(), py.None(), false), Some(&kwargs))?; - let instruction = PyInstruction { + let instruction = PyGate { qubits: 2, clbits: 0, params: 1, op_name: "unitary".to_string(), - control_flow: false, - instruction: unitary_gate.unbind(), + gate: unitary_gate.unbind(), }; let qubit = layer_index * 2; Ok(( - PackedOperation::from_instruction(Box::new(instruction)), + PackedOperation::from_gate(Box::new(instruction)), smallvec![Param::Obj(unitary.unbind().into())], vec![permutation[qubit], permutation[qubit + 1]], vec![], diff --git a/test/python/transpiler/test_preset_passmanagers.py b/test/python/transpiler/test_preset_passmanagers.py index 0941039cdde..1ecee97a5ed 100644 --- a/test/python/transpiler/test_preset_passmanagers.py +++ b/test/python/transpiler/test_preset_passmanagers.py @@ -22,6 +22,7 @@ from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister from qiskit.circuit import Qubit, Gate, ControlFlowOp, ForLoopOp +from qiskit.circuit.library import quantum_volume from qiskit.compiler import transpile from qiskit.transpiler import CouplingMap, Layout, PassManager, TranspilerError, Target from qiskit.circuit.library import U2Gate, U3Gate, QuantumVolume, CXGate, CZGate, XGate @@ -343,6 +344,24 @@ def test_v1(self, circuit, level, backend): ) self.assertIsInstance(result, QuantumCircuit) + @data(0, 1, 2, 3) + def test_quantum_volume_function_transpile(self, opt_level): + """Test quantum_volume transpilation.""" + qc = quantum_volume(10, 10, 12345) + backend = GenericBackendV2( + num_qubits=100, + basis_gates=["cz", "rz", "sx", "x", "id"], + coupling_map=CouplingMap.from_grid(10, 10), + ) + pm = generate_preset_pass_manager(opt_level, backend) + res = pm.run(qc) + for inst in res.data: + self.assertTrue( + backend.target.instruction_supported( + inst.operation.name, qargs=tuple(res.find_bit(x).index for x in inst.qubits) + ) + ) + @ddt class TestPassesInspection(QiskitTestCase):