-
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
Feature: Approximate 1Q synthesis #7084
Feature: Approximate 1Q synthesis #7084
Conversation
qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py
Outdated
Show resolved
Hide resolved
# incorporate a possible trace distance from approximate synthesis | ||
operator = old_run[0].op.to_matrix() | ||
for gate in old_run[1:]: | ||
operator = gate.op.to_matrix().dot(operator) | ||
decomp_unitary = new_circ[0][0].to_matrix() if new_circ else np.eye(2) | ||
for gate, _, _ in new_circ[1:]: | ||
decomp_unitary = gate.to_matrix().dot(decomp_unitary) | ||
trace_pairing = np.trace(decomp_unitary @ np.conj(operator.data).transpose(1, 0)) | ||
new_infidelity += (4 - abs(trace_pairing) ** 2) / 6 |
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.
Have you done any perf testing? If this recalculation of the infidelity becomes a bottleneck we may prefer to pass it out from the decomposer along with the decomposed circuit?
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.
No, none. I expect this to have worse performance, but I couldn't guess at a factor. Matthew has previously shown me how to run benchmarks; I'll try to remember how that goes.
Co-authored-by: Lev Bishop <[email protected]>
As written, this comes with significant performance degradation. I haven't run
versus on this branch:
Not great. |
Ouch. |
As of recent commits, this is now
which is still noticeably worse, but approaching tolerable. |
Pull Request Test Coverage Report for Build 1423654641
💛 - Coveralls |
operator = old_run[0].op.to_matrix() | ||
for gate in old_run[1:]: | ||
operator = gate.op.to_matrix().dot(operator) |
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.
Don't we already have this unitary previously calculated? Not sure how expensive this recalculation is, might matter for long runs
hi @ecpeterson are you still working on this? |
@javabster My employer's attention is elsewhere, so I am no longer working on this. :) The main outstanding thread of work was some performance degradation, but who knows how the code has drifted in the intervening 18mo. |
Thanks for letting us know @ecpeterson, I'll close this PR but if you'd like to return to it at a later date just let us know and we can reopen |
cc @levbishop , @1ucian0
Summary
This (draft) PR synthesizes 1Q operators up to approximation. Aside from inherent utility, I hope that this stems the warnings reported in #7033 and #7042. This carries on (though in a different direction) from Lev's comment.
Details and comments
The changed regions of code are:
_circuit_psx_gen
takes (optional) fidelity estimates for the circuit generated byxfun
andxpifun
and selects a circuit from a few templates based on best approximation + fidelity distance from the target + operational cost._circuit_*
wrappers take an (optional)fidelity_mapping
argument which reports fidelity estimates for operations appearing on the relevant qubit.At the moment, this is aAt the moment, this takes the form of aCallable
so that I can bind the qubit index in the backend property lookup, but passing around anonymous lambdas is not totally desirable.defaultdict
, typically populated from whateverBackendProperties
is around.Optimize1qGatesDecomposition
receives aBackendProperties
object and threads that information through to the decomposition calls.Some missing features are:
I would particularly appreciate comments on: