Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix UnitarySynthesis for 3+ qubits when compiled for a backend (backport #13591) #13619

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 7, 2025

Summary

When encountering a 3+ qubit UnitaryGate, UnitarySynthesis currently replaces the whole dag with the definition of the block instead of appending it, see

Details and comments

This also leads to #13586 because the qubit/clbit interners are overwritten, but maybe more importantly this can lead to issues when multiple 3-qubit blocks are present in the circuit. E.g. running

import numpy as np
from qiskit.quantum_info import Operator
from qiskit.circuit.library import UnitaryGate
from qiskit import QuantumCircuit, transpile
from qiskit_ibm_runtime.fake_provider import FakeSherbrooke

backend = FakeSherbrooke()

x = QuantumCircuit(3)
x.x(2)
x_mat = Operator(x)

qc = QuantumCircuit(3, 1)
qc.unitary(x_mat, range(3))
qc.unitary(np.eye(2 ** 3), range(3))

tqc = transpile(qc, backend, optimization_level=0)
print(tqc.count_ops())

produces an empty circuit, since the last block implements the identity.

Some additional tests, such as the precise case of #13586 and a series of 3q UnitaryGates, should be added.


This is an automatic backport of pull request #13591 done by [Mergify](https://mergify.com).

)

* Fix unitary synthesis for 3+ q

* Update releasenotes/notes/fix-unitary-synthesis-3q-2b2de5305bfd11ff.yaml

Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>

* add more tests

* use == over equiv

---------

Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
(cherry picked from commit 86a5325)
@mergify mergify bot requested a review from a team as a code owner January 7, 2025 12:58
@qiskit-bot
Copy link
Collaborator

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:

  • @Qiskit/terra-core

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository labels Jan 7, 2025
@github-actions github-actions bot added this to the 1.3.2 milestone Jan 7, 2025
@Cryoris Cryoris enabled auto-merge January 7, 2025 13:22
@coveralls
Copy link

Pull Request Test Coverage Report for Build 12652064901

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 88.947%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 93.18%
crates/qasm2/src/lex.rs 3 92.73%
Totals Coverage Status
Change from base Build 12631844630: 0.02%
Covered Lines: 79149
Relevant Lines: 88984

💛 - Coveralls

@Cryoris Cryoris added this pull request to the merge queue Jan 7, 2025
Merged via the queue into stable/1.3 with commit e33da2a Jan 7, 2025
20 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Rust This PR or issue is related to Rust code in the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants