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 (backport #13095) #13097

Closed mergify[bot] closed 2 months ago

mergify[bot] 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.


This is an automatic backport of pull request #13095 done by Mergify.

qiskit-bot commented 2 months ago

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 10725172384

Details


Files with Coverage Reduction New Missed Lines %
crates/circuit/src/packed_instruction.rs 1 96.21%
crates/accelerate/src/results/marginalization.rs 1 90.45%
crates/accelerate/src/synthesis/clifford/utils.rs 1 78.06%
crates/qasm2/src/lex.rs 2 92.98%
crates/circuit/src/circuit_instruction.rs 7 86.33%
crates/circuit/src/operations.rs 7 88.31%
<!-- Total: 19 -->
Totals Coverage Status
Change from base Build 10719167310: 0.005%
Covered Lines: 66861
Relevant Lines: 74473

💛 - Coveralls