-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Round durations in GenericBackendV2
#11780
Conversation
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 8392874457Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels sufficiently non-critical to me that my vote would be to merge it in 1.0.1 rather than post-rc, but I don't feel overly strongly.
if duration is not None: | ||
# Ensure exact conversion of duration from seconds to dt | ||
dt = _QUBIT_PROPERTIES["dt"] | ||
duration = round(duration / dt) * dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this can cause the duration to fall outside the distribution it was drawn from. I don't know how much you care about that particular edge case, but strictly it's possible. Consider drawing from the uniform distribution [0.09, 0.15)
with dt=0.04
- value arbitrarily close to 0.09 and 0.15 will be rounded to 0.08 and 0.16 respectively, outside the range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElePT perhaps you can clamp the result to the lower and upper bounds here, and ensure those bounds are a multiple of dt
when declaring the constants for the ranges?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion @kevinhartman, I applied it in 0bb2fcd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for the changes! 😄
* Round durations * Update generic_backend_v2.py * Clamp rounded durations (cherry picked from commit 35a8e53)
* Round durations * Update generic_backend_v2.py * Clamp rounded durations (cherry picked from commit 35a8e53) Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Summary
This PR makes sure that the conversion of
GenericBackendV2
instruction durations todt
is exact to avoid user warnings during scheduling of type:UserWarning: Duration is rounded to 616 [dt] = 1.367520e-07 [s] from 1.366887e-07 [s]
Given that the durations are sampled randomly, and the rounded duration is the one used in the scheduling passes, we might as well make sure in advance that the conversion from seconds to dt will be exact and doesn't raise warnings.
Details and comments
I am not sure this qualifies as a bugfix but I think it improves the readability of the test logs. For example, for
test_scheduling_backend_v2
intest/python/compiler/test_transpiler.py
. Before:After: