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

Optimize1qGates should allow rounding when calculating theta #4015

Merged
merged 10 commits into from
Apr 3, 2020

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Mar 24, 2020

I noticed floating-point impression makes Optimize1qGates missing some situations to reduce the U-gate arity. For example:

circuit.u3(1.5707963267948961, 1.0471975511965971, 0.7853981633974489, qr[0])

is "almost"

circuit.u2(np.pi/3, np.pi/4, qr[0])

This PR fixes that.

@1ucian0 1ucian0 added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Mar 24, 2020
@1ucian0 1ucian0 removed the Changelog: Bugfix Include in the "Fixed" section of the changelog label Mar 24, 2020
@1ucian0 1ucian0 added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Mar 25, 2020
@1ucian0 1ucian0 added this to the 0.13 milestone Mar 25, 2020
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.

LGTM, thanks

@mergify mergify bot merged commit 947daa1 into Qiskit:master Apr 3, 2020
@1ucian0 1ucian0 deleted the round_Optimize1qGates branch April 5, 2020 11:49
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Jul 31, 2020
In Qiskit#4015 a fix was added to handle fp precision issues around 0
comparions that involved calling np.round to adjust the values for
comparison. However this is kind of an antipattern for doing this type
of check, since round involves making a copy of the input and truncating
the value. Instead this commit adjusts the rounding to use a more
standard pattern, using abs and an adjustable EPS value to use for
comparing to 0. This should avoid the unecessary overhead caused by
using round().
mergify bot pushed a commit that referenced this pull request Jul 31, 2020
In #4015 a fix was added to handle fp precision issues around 0
comparions that involved calling np.round to adjust the values for
comparison. However this is kind of an antipattern for doing this type
of check, since round involves making a copy of the input and truncating
the value. Instead this commit adjusts the rounding to use a more
standard pattern, using abs and an adjustable EPS value to use for
comparing to 0. This should avoid the unecessary overhead caused by
using round().

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
…4015)

* allow rounding when calculating theta

* docstring

* release notes

* fix

* lint

* more test

* reduce diff

* round after the mod

* no release notes
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants