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

Don't substitute ideal gates in target with Optimize1qGatesDecomposition #11351

Merged
merged 5 commits into from
Dec 1, 2023

Conversation

mtreinish
Copy link
Member

Summary

This commit fixes an issue in Optimize1qGatesDecomposition where the pass would defer to synthesized gates if the output from synthesis was ideal even if the input gate was also ideal. This typically comes up in simulators where there are no error rates for any gates and everything is listed as ideal. This would cause the transpiler to translate gates unnecessarily which was unexpected. This commit fixes this by adding an additional check to the substitution condition to ensure we're only substituting a gate if it's not in the target (when they're all ideal).

Details and comments

Fixes #10568

This commit fixes an issue in Optimize1qGatesDecomposition where the
pass would defer to synthesized gates if the output from synthesis was
ideal even if the input gate was also ideal. This typically comes up in
simulators where there are no error rates for any gates and everything
is listed as ideal. This would cause the transpiler to translate gates
unnecessarily which was unexpected. This commit fixes this by adding an
additional check to the subsitution condition to ensure we're only
substituting a gate if it's not in the target (when they're all ideal).

Fixes Qiskit#10568
@mtreinish mtreinish added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler labels Nov 30, 2023
@mtreinish mtreinish added this to the 0.45.2 milestone Nov 30, 2023
@mtreinish mtreinish requested a review from a team as a code owner November 30, 2023 17:07
@coveralls
Copy link

coveralls commented Nov 30, 2023

Pull Request Test Coverage Report for Build 7052106759

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.006%) to 87.454%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 2 92.42%
Totals Coverage Status
Change from base Build 7049384648: 0.006%
Covered Lines: 59838
Relevant Lines: 68422

💛 - Coveralls

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

This seems like a sensible and easy fix to me.

@jakelishman jakelishman added this pull request to the merge queue Nov 30, 2023
Merged via the queue into Qiskit:main with commit f12db3b Dec 1, 2023
14 checks passed
mergify bot pushed a commit that referenced this pull request Dec 1, 2023
…ion (#11351)

* Don't substitute ideal gates in target with Optimize1qGatesDecomposition

This commit fixes an issue in Optimize1qGatesDecomposition where the
pass would defer to synthesized gates if the output from synthesis was
ideal even if the input gate was also ideal. This typically comes up in
simulators where there are no error rates for any gates and everything
is listed as ideal. This would cause the transpiler to translate gates
unnecessarily which was unexpected. This commit fixes this by adding an
additional check to the subsitution condition to ensure we're only
substituting a gate if it's not in the target (when they're all ideal).

Fixes #10568

* Update releasenotes/notes/fix-optimize-1q-sim-407b88e45e6062b6.yaml

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Update qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py

* Fix formatting

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
(cherry picked from commit f12db3b)
@mtreinish mtreinish deleted the prefer-original-gate-optimize-1q branch December 1, 2023 01:00
github-merge-queue bot pushed a commit that referenced this pull request Dec 1, 2023
…ion (#11351) (#11359)

* Don't substitute ideal gates in target with Optimize1qGatesDecomposition

This commit fixes an issue in Optimize1qGatesDecomposition where the
pass would defer to synthesized gates if the output from synthesis was
ideal even if the input gate was also ideal. This typically comes up in
simulators where there are no error rates for any gates and everything
is listed as ideal. This would cause the transpiler to translate gates
unnecessarily which was unexpected. This commit fixes this by adding an
additional check to the subsitution condition to ensure we're only
substituting a gate if it's not in the target (when they're all ideal).

Fixes #10568

* Update releasenotes/notes/fix-optimize-1q-sim-407b88e45e6062b6.yaml

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Update qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py

* Fix formatting

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
(cherry picked from commit f12db3b)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
mtreinish added a commit to mtreinish/qiskit-aer that referenced this pull request May 17, 2024
This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes Qiskit#2141
mtreinish added a commit to mtreinish/qiskit-aer that referenced this pull request May 17, 2024
This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes Qiskit#2141
doichanj pushed a commit to Qiskit/qiskit-aer that referenced this pull request May 20, 2024
This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes #2141
doichanj pushed a commit to doichanj/qiskit-aer that referenced this pull request May 23, 2024
This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes Qiskit#2141
doichanj added a commit to Qiskit/qiskit-aer that referenced this pull request May 31, 2024
* release 0.14.2

* Disable test shot_branching on MacOS (#2143)

* remove test_shot_branching

* disable sho_branching tests on MacOS

* fix test

* fix test

* format

* fix test_shot_branching

* fix test_runtime_parameterization

* fix tests for the latest Qiskit (#2138)

* Remove qiskit aer translation stage (#2142)

This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes #2141

* Fix issue 2084 again (#2119)

* Fix issue 2084 again

* format

* fix test

* fix test

* Always hook omp functions in Mac (#2128)

* always hook omp functions in Mac

* fix recent test failures with the latest qiskit

---------

Co-authored-by: Jun Doi <doichan@jp.ibm.com>

* Add simulator_metadata in metadata of SamplerV2 (#2109)

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>

* Fix cuStateVec_enable option (#2146)

* Fix cuStateVec_enable option

* fix function name

* Add support for rotation gates (#2147)

* add rotation gates

* add cr* gates to operations.hpp

* fix test for stabilkize/extended-stabilizer

* fix test again

* Fix deterministic measure of stabilizer (#2132)

* Fix deterministic measure of stabilizer

* fix accumulation in loop

* format

---------

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>

* Fix init of EstimatorV2 and SamplerV2 (#2120)

* fix init of EstimatorV2 and SamplerV2 to handle method

* add release note

* fix from_backend and example in README

* remove setting density_matrix

* Fix deploy.yml (#2110)

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Add support for ECR gate to MPS (#2137)

* Add support for ECR gate

* replace is not to !=

* fix release note

* Fix ecr implementation for stabilizer/extended-stabilizer

* Handle gates with ctrl_stete=0 (#2148)

* handle cx gate with ctrl_stete=0

* add handling *_o0, add test for cx_o0

* format

* fix test

* fix test

* fix test cx

* fix to handle multiple control states

* fix ctrl_state

* format

* resolve conflict again

* fix aer_compiler

* fix random seed (#2151)

Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>

* Move delay gate to custom instructions (#2153)

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Hiroshi Horii <hhorii@users.noreply.github.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
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 mod: transpiler Issues and PRs related to Transpiler 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.

Optimize1qGatesDecomposition doesn't account for ideal gates correctly
3 participants