-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add 2q fractional gates to the ConsolidateBlocks
transpiler pass
#13884
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
One or more of the following people are relevant to this code:
|
The only test currently failing is:
This test was added in #13450 to handle issue #13438, and I wonder if we should remove it. @mtreinish @ElePT - what's your opinion? the original circuit is:
the circuit after basis translation is:
The circuit after optimization_level 2 or 3 transpilation is:
The reason that this circuit is being consolidated is that it originally contains CZ gates. If it had contained only RZZ gates, then it would not had been consolidated. I think that it would be better handled in #13419 (which should take into account the 1-qubit gates). |
consolidate_pass = ConsolidateBlocks(basis_gates=["rzz", "rx", "rz"]) | ||
res = consolidate_pass(qc) | ||
self.assertEqual({"unitary": 1}, res.count_ops()) | ||
self.assertEqual(Operator.from_circuit(qc), Operator(res.data[0].operation.params[0])) |
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.
Note that due to the TwoQubitControlledUDecomposer
synthesis algorithm, the synthesized circuit is:
q_0: ──────────■──────────────────
┌───────┐ │ZZ(-0.3) ┌───────┐
q_1: ┤ Rx(π) ├─■─────────┤ Rx(π) ├
└───────┘ └───────┘
and not just RZZGate(0.3)
ConsolidateBlocks
transpiler passConsolidateBlocks
transpiler pass
Pull Request Test Coverage Report for Build 13636391692Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - 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.
Thanks Shelly! The PR looks good, I just left two small comments that should be easy to look into.
use crate::two_qubit_decompose::{TwoQubitBasisDecomposer, TwoQubitControlledUDecomposer}; | ||
|
||
#[allow(clippy::large_enum_variant)] | ||
#[derive(Clone, Debug, FromPyObject)] |
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 don't see any public uses of DecomposerType
, so the enum can probably be kept private, right? Similarly, I didn't find where is the FromPyObject
trait used, but I might have missed it.
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.
FromPyObject
is used to call either the TwoQubitBasisDecomposer
or the TwoQubitControlledUDecomposer
from python, see this comment:
#13884 (comment)
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.
removing pub
from the enum
produces this warning:
warning: type consolidate_blocks::DecomposerType is more private than the item consolidate_blocks
CXGate(), basis_fidelity=approximation_degree or 1.0 | ||
elif kak_param_gates: | ||
self.decomposer = TwoQubitControlledUDecomposer( | ||
KAK_GATE_PARAM_NAMES[kak_param_gates.pop()] |
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 remember a discussion we had in unitary synthesis where we agreed not to use pop
because of result reproducibility. I think the same logic would apply in this case.
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.
done in 9095358
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.
LGTM! thanks for answering my questions.
…13884) * add TwoQubitControlledUDecomposer to init file * add kak parametrized gates * add a test for parametrized gates * add num_basis_gates_inner function to TwoQubitControlledUDecomoser class * add TwoQubitControlledUDecomposer to consolidate_blocks function * add TwoQubitControlledUDecomposer to ConsolidateBlocks pass * add FromPyObject to enum * replace _inner_decomposition by _inner_decomposer * update rust code * add self.gate_name to 2-qubit decmposer classes * extend test_collect_rzz test * add release notes * update test_no_kak_gates_in_present_pm * remove commented line * add allow clippy * do not pop
For those worried that this bounced off the merge queue twice, looking at the log those failures were caused by issues with the latest aer release and not issues in this pr itself. |
Summary
With the introduction of new 2q-fractional gates, such as
RZZGate
as part of the QPU, we add them to theConsolidateBlocks
transpiler pass.https://www.ibm.com/quantum/blog/fractional-gates
This PR should close #13428
Details and comments
Note that this PR may be eventually superseded by #13419