-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Avoid Operator construction overhead in Optimize 1q decomposition pass #5909
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
Conversation
This commit further tunes the performance of the optimize 1q decomposition pass. Previously, the pass was constructing an operator using the Operator qi class and then calling compose() on each gate in the run to find the overall unitary of the run. However, doing this was constructing a lot of intermediate operators that weren't needed and just added extra overhead. To avoid that overhead this commit relies on the raw numpy calculations to build the matrix for the overall operator and then wraps that in an Operator() object only once when we go to call the OneQubitEulerDecomposer.
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.
I think this looks good, and will likely go a long way to making Optimize1qGateDecompositions
more comparable in performance to Optimize1qGates
. Do you have any preliminary performance numbers?
qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py
Outdated
Show resolved
Hide resolved
qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py
Outdated
Show resolved
Hide resolved
I did some quick manual benchmarking (only one sample each run so not sure what the error is) with a
From when I profiled the pass recently: #5775 (comment) the biggest bottleneck is the decomposer, so it looks like the 2x difference, which is only ~40us, ends up lost in the noise. |
Summary
This commit further tunes the performance of the optimize 1q
decomposition pass. Previously, the pass was constructing an operator
using the Operator qi class and then calling compose() on each gate in
the run to find the overall unitary of the run. However, doing this was
constructing a lot of intermediate operators that weren't needed and
just added extra overhead. To avoid that overhead this commit relies on
the raw numpy calculations to build the matrix for the overall operator
and then wraps that in an Operator() object only once when we go to call
the OneQubitEulerDecomposer.
Details and comments