Skip to content
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

Fix Rust-space TwoQubitBasisDecomposer for non-standard KAK gate #13014

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Aug 22, 2024

Summary

Proposal to fix #12998. I can probably extend the unit tests further.

Details and comments

@ElePT ElePT marked this pull request as ready for review August 22, 2024 09:08
@ElePT ElePT requested review from alexanderivrii, ShellyGarion and a team as code owners August 22, 2024 09:08
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core
  • @kevinhartman
  • @levbishop
  • @mtreinish

@ElePT ElePT added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Aug 22, 2024
@ElePT ElePT added this to the 1.2.1 milestone Aug 22, 2024
@ElePT ElePT changed the title Fix Rust-space TwoQubitBasisDecomposer for not Rust-space standard KAK gate Fix Rust-space TwoQubitBasisDecomposer for non-standard KAK gate Aug 22, 2024
@ElePT ElePT added the Rust This PR or issue is related to Rust code in the repository label Aug 22, 2024
@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Aug 22, 2024
@coveralls
Copy link

coveralls commented Aug 22, 2024

Pull Request Test Coverage Report for Build 10527903608

Details

  • 44 of 44 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.07%) to 89.644%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 5 92.23%
Totals Coverage Status
Change from base Build 10525107270: 0.07%
Covered Lines: 67847
Relevant Lines: 75685

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, the fix looks good, just one comment on the tests.

Reproduce from: https://github.com/Qiskit/qiskit/issues/12998
"""
# note that `CXGate(ctrl_state=0)` is not handled as a "standard" gate.
TwoQubitBasisDecomposer(CXGate(ctrl_state=0))(CXGate())
Copy link
Member

Choose a reason for hiding this comment

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

The bug was only present when building the circuit. Can you update this to pass it a unitary matrix to synthesize and maybe assert the output circuit's operator is equivalent to the input and your pygate is correctly used.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I misread this it is creating a circuit from cx's matrix. It'd still be good to add the assertions though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's totally on me, I just copied the reproducing example without trying to make it readable. It should look better now :)

@mtreinish mtreinish enabled auto-merge August 23, 2024 15:02
@mtreinish mtreinish added this pull request to the merge queue Aug 23, 2024
Merged via the queue into Qiskit:main with commit a4bf87b Aug 23, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Aug 23, 2024
…13014)

* Get rid of encoded assumption in TwoQubitBasisDecomposer that the given KAK gate is a Rust-space StandardGate

* Improve unit test

* Update test/python/synthesis/test_synthesis.py

Co-authored-by: Matthew Treinish <[email protected]>

---------

Co-authored-by: Matthew Treinish <[email protected]>
(cherry picked from commit a4bf87b)
github-merge-queue bot pushed a commit that referenced this pull request Aug 27, 2024
…13014) (#13026)

* Get rid of encoded assumption in TwoQubitBasisDecomposer that the given KAK gate is a Rust-space StandardGate

* Improve unit test

* Update test/python/synthesis/test_synthesis.py

Co-authored-by: Matthew Treinish <[email protected]>

---------

Co-authored-by: Matthew Treinish <[email protected]>
(cherry picked from commit a4bf87b)

Co-authored-by: Elena Peña Tapia <[email protected]>
Co-authored-by: Elena Peña Tapia <[email protected]>
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 Rust This PR or issue is related to Rust code in the repository stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust-space TwoQubitBasisDecomposer fails if KAK gate is not Rust-space standard
4 participants