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

HLS fix to not synthesize instructions already supported #13417

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

alexanderivrii
Copy link
Contributor

@alexanderivrii alexanderivrii commented Nov 10, 2024

Summary

Fixes #13412.

Needs to be backported to 1.3.0.

Details and comments

Previously HighLevelSynthesis synthesized an instruction for which a synthesis plugin was available, even when the instruction was already considered supported (either supported by the target or a part of basis_gates). This commit fixes this behavior.
Update: the control-flow operations (e.g. for-loop) belong to basis_gates but need to be recursively synthesized.

Even though the problem was only discovered for "PauliEvolution" gates also added for 1.3, the incorrect behavior for other high-level gates existed before, so I added release notes. I was not sure if they should be under releasenotes/notes/1.3 or not.

@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@alexanderivrii alexanderivrii added this to the 1.3.0 milestone Nov 10, 2024
@alexanderivrii alexanderivrii added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Nov 10, 2024
The control-flow operations such as 'for-loop` are considered to be a
part of 'basis_gates`, yet they need to be recursively synthesized.
@coveralls
Copy link

coveralls commented Nov 10, 2024

Pull Request Test Coverage Report for Build 11813177643

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

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 35 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.911%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 92.2%
crates/qasm2/src/lex.rs 4 91.98%
qiskit/transpiler/passes/synthesis/high_level_synthesis.py 12 92.94%
crates/qasm2/src/parse.rs 18 96.69%
Totals Coverage Status
Change from base Build 11749692210: -0.02%
Covered Lines: 79044
Relevant Lines: 88902

💛 - Coveralls

@mtreinish mtreinish added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Nov 10, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check: this bug with PauliEvolution only came up in 1.3, but already in 1.2 this was wrong. However, we didn't notice with PauliEvolution gate though, since we didn't have plugins, but it could've been triggered with something else, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly!

Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

LGTM for this fix, thank you!

However, I’m mildly unhappy about that special treatment of control flow… there’s somehow a different meaning to basis gates. Usually a name being in basis_gates means we can run it, but for control_flow that’s not quite true, since we still need to synthesize it’s insides 🤔

@alexanderivrii
Copy link
Contributor Author

However, I’m mildly unhappy about that special treatment of control flow… there’s somehow a different meaning to basis gates. Usually a name being in basis_gates means we can run it, but for control_flow that’s not quite true, since we still need to synthesize it’s insides 🤔

Thanks @Cryoris! I completely agree, I would also like to see a better separation between gates and between control-flow logic. However, for the purpose of the bug fix. Is there anything specific I should do?

@Cryoris Cryoris added this pull request to the merge queue Nov 14, 2024
@Cryoris
Copy link
Contributor

Cryoris commented Nov 14, 2024

No I agree this is the correct fix for now, this was more a comment to discuss this in general later on 🙂

Merged via the queue into Qiskit:main with commit b9d5c9c Nov 14, 2024
17 checks passed
mergify bot pushed a commit that referenced this pull request Nov 14, 2024
* HLS fix to not synthesize instructions already supported

* reno

* fix for control-flow-operations

The control-flow operations such as 'for-loop` are considered to be a
part of 'basis_gates`, yet they need to be recursively synthesized.

* using faster is_control_flow check

* Update test/python/transpiler/test_high_level_synthesis.py

Co-authored-by: Julien Gacon <[email protected]>

---------

Co-authored-by: Julien Gacon <[email protected]>
(cherry picked from commit b9d5c9c)
github-merge-queue bot pushed a commit that referenced this pull request Nov 14, 2024
…3441)

* HLS fix to not synthesize instructions already supported

* reno

* fix for control-flow-operations

The control-flow operations such as 'for-loop` are considered to be a
part of 'basis_gates`, yet they need to be recursively synthesized.

* using faster is_control_flow check

* Update test/python/transpiler/test_high_level_synthesis.py

Co-authored-by: Julien Gacon <[email protected]>

---------

Co-authored-by: Julien Gacon <[email protected]>
(cherry picked from commit b9d5c9c)

Co-authored-by: Alexander Ivrii <[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 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.

HighLevelSynthesis raises an error with 1.3.0rc1 (no error with 1.2.4 and main branch)
5 participants