Skip to content

Fix UnitarySynthesis to respect synth_gates #14345

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025

Conversation

yoshum
Copy link
Contributor

@yoshum yoshum commented May 11, 2025

Fixes #14343

Summary

This commit fixes UnitarySynthesis. It has a parameter synth_gates, which is meant to be a list of gates that are synthesized. However, the previous implementation did not respect this parameter, and only synthesized the gates named unitary. This commit fixes this issue by checking if gate's name is in synth_gates.

Details and comments

When a non-default method is specified, the DAG nodes are traversed in UnitarySynthesis._run_main_loop. There, the name of the node is checked, and in the original implementation, the operation is synthesized if the name is unitary. This PR fixes this condition so that the synthesis takes place if the name is in synth_gates.

When the method argument is not given, UnitarySynthesis invokes the rust version of run_main_loop, which basically has the same structure. The PR also fixes it.

yoshum added 2 commits May 11, 2025 15:49
This commit fixes UnitarySynthesis. It has a parameter `synth_gates`,
which is meant to be a list of gates that are synthesized. However,
the previous implementation did not respect this parameter, and only
synthesized the gates named `unitary`. This commit fixes this issue by
checking if gate's name is in `synth_gates`.
@yoshum yoshum requested a review from a team as a code owner May 11, 2025 14:53
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label May 11, 2025
@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

@CLAassistant
Copy link

CLAassistant commented May 11, 2025

CLA assistant check
All committers have signed the CLA.

@ShellyGarion ShellyGarion added synthesis Changelog: Bugfix Include in the "Fixed" section of the changelog labels May 11, 2025
@yoshum yoshum force-pushed the fix/unitarysynthesis-synth_gates branch from 04f57b4 to 6be9a0f Compare May 12, 2025 10:11
@alexanderivrii
Copy link
Member

Thank you for the contribution! This looks great. Could you also add release notes?

Copy link
Member

@alexanderivrii alexanderivrii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yoshum
Copy link
Contributor Author

yoshum commented May 12, 2025

Thank you for the review!

@mtreinish mtreinish added this to the 2.0.1 milestone May 12, 2025
@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label May 12, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 14971837897

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 7 of 8 (87.5%) changed or added relevant lines in 2 files are covered.
  • 16 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.007%) to 88.743%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/transpiler/src/passes/unitary_synthesis.rs 6 7 85.71%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 92.48%
crates/cext/src/circuit.rs 12 80.41%
Totals Coverage Status
Change from base Build 14937574463: 0.007%
Covered Lines: 76076
Relevant Lines: 85726

💛 - Coveralls

@alexanderivrii alexanderivrii added this pull request to the merge queue May 12, 2025
Merged via the queue into Qiskit:main with commit 0c2ce64 May 12, 2025
24 checks passed
mergify bot pushed a commit that referenced this pull request May 12, 2025
* Fix UnitarySynthesis to respect synth_gates

This commit fixes UnitarySynthesis. It has a parameter `synth_gates`,
which is meant to be a list of gates that are synthesized. However,
the previous implementation did not respect this parameter, and only
synthesized the gates named `unitary`. This commit fixes this issue by
checking if gate's name is in `synth_gates`.

* Add tests for UnitarySynthesis' synth_gates

* Fix the default Rust impl of UnitarySynthesis

* Add the release note for #14345

(cherry picked from commit 0c2ce64)

# Conflicts:
#	crates/accelerate/src/unitary_synthesis.rs
github-merge-queue bot pushed a commit that referenced this pull request May 13, 2025
* Fix UnitarySynthesis to respect synth_gates (#14345)

* Fix UnitarySynthesis to respect synth_gates

This commit fixes UnitarySynthesis. It has a parameter `synth_gates`,
which is meant to be a list of gates that are synthesized. However,
the previous implementation did not respect this parameter, and only
synthesized the gates named `unitary`. This commit fixes this issue by
checking if gate's name is in `synth_gates`.

* Add tests for UnitarySynthesis' synth_gates

* Fix the default Rust impl of UnitarySynthesis

* Add the release note for #14345

(cherry picked from commit 0c2ce64)

# Conflicts:
#	crates/accelerate/src/unitary_synthesis.rs

* Resolve the merge conflict (#14357)

---------

Co-authored-by: Shuhei M. Yoshida <17794644+yoshum@users.noreply.github.com>
rahaman-quantum pushed a commit to rahaman-quantum/qiskit that referenced this pull request Jun 20, 2025
* Fix UnitarySynthesis to respect synth_gates

This commit fixes UnitarySynthesis. It has a parameter `synth_gates`,
which is meant to be a list of gates that are synthesized. However,
the previous implementation did not respect this parameter, and only
synthesized the gates named `unitary`. This commit fixes this issue by
checking if gate's name is in `synth_gates`.

* Add tests for UnitarySynthesis' synth_gates

* Fix the default Rust impl of UnitarySynthesis

* Add the release note for Qiskit#14345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo stable backport potential The bug might be minimal and/or import enough to be port to stable synthesis
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

UnitarySynthesis does not respect synth_gates
7 participants