Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Restrict `Split2QUnitaries` to run on `UnitaryGate`s only #13095

Closed Cryoris closed 2 months ago

Cryoris commented 2 months ago

Summary

Fixes the remaining problems with #12970.

Details and comments

If we run Split2QUnitaries with an incomplete 1-q basis gate set, we can end up in the situation where a supported gate is split into 2 UnitaryGate objects that might not be representable in the current basis gate set. For example

from qiskit import QuantumCircuit, transpile
from qiskit.circuit.library import *

gate = PauliGate("XX")

qc = QuantumCircuit(2)
qc.append(gate, [0, 1])

basis_gates = ["x"]  # gate decomposes into XX

circuit = transpile(qc, basis_gates=basis_gates, optimization_level=2)  # fails -- cannot map U to the basis

This PR fixes the behavior by only running on UnitaryGate objects -- hence not changing the gate types existing in the circuit.

qiskit-bot commented 2 months ago

One or more of the following people are relevant to this code:

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10723089932

Details


Files with Coverage Reduction New Missed Lines %
crates/circuit/src/dag_node.rs 3 81.2%
crates/circuit/src/operations.rs 3 88.5%
crates/qasm2/src/lex.rs 4 91.73%
crates/circuit/src/circuit_instruction.rs 5 85.14%
<!-- Total: 15 -->
Totals Coverage Status
Change from base Build 10721003464: 0.02%
Covered Lines: 72657
Relevant Lines: 81481

💛 - Coveralls