Use optimized AND for decomposition #1202
Conversation
This allows the "unrestricted" configuration to use an optimized `AND` for multi-controlled decomposition that relies on measurment-based adjoint. The existing `PhaseCCX` will still be used for "base" configuration since branching measurement is not allowed there. Fixes #1137
|
Change in memory usage detected by benchmark. Memory Report for 5675de4
|
Benchmark for 5675de4Click to view benchmark
|
msoeken
left a comment
There was a problem hiding this comment.
Looks good to me, thank you.
We could replace M.Q.Unstable.Arithmetic.ApplyAndAssuming0Target by AND in this PR.
Further, I suggest to consider making AND a public operation.
We'll definitely be discussing when/how to expose this as a public API. For now though, we can't have them both use the same utility function because they are in different namespaces and cannot see the callables marked as |
We could make it public in the unstable namespace to avoid duplication before discussing the public API in a non-unstable namespace. |
That's certainly possible, yes. I just would feel a bit awkward about having most callables in the Microsoft.Quantum.Intrinsic namespace depend on something from an unstable namespace. Feels a bit like an inversion... The other concern I have is with the adjoint and how it is used, but that might be a longer conversation than just for this PR. What I'd like is to get this merged and then open an issue about making AND a supported intrinsic in QIR and public in Q#. Then we can get into the details of the design in that issue. |
|
Change in memory usage detected by benchmark. Memory Report for ee2263c
|
Benchmark for ee2263cClick to view benchmark
|
DmitryVasilevsky
left a comment
There was a problem hiding this comment.
Approving library change.
This allows the "unrestricted" configuration to use an optimized
ANDfor multi-controlled decomposition that relies on measurement-based adjoint. The existingPhaseCCXwill still be used for "base" configuration since branching measurement is not allowed there.Fixes #1137