Open jiannanWang opened 7 months ago
Right now, all the chained methods on Gate
, like control
and power
do things eagerly and (largely) non-symbolically. This means that your code is attempting to build an 11q matrix and decompose it. It so happens that there are a couple of tensor contractions we do in places that have happened to explode here, but that eager synthesis is the main problem you're seeing.
You can switch to our (somewhat experimental) symbolic representations of control
and power
operations by passing annotated=True
to the Gate.control
and Gate.power
methods, but beware that at the moment, we'll still be using inefficient syntheses during transpilation for those. We're working on improving that, though - you can see some discussion in #11823.
I think this method should work for generating a multi-controlled RZ
gate:
q_controls = list(range(num_ctrl_qubits))
q_target = num_ctrl_qubits
qc.mcrz(0.7773868957129396, q_controls, q_target)
Sorry, this comment is relevant for RZGate
or RXGate
, but not directly for RZXGate
.
However, as you can decompose RZXGate
into CX
, RX
, RY
, RZ
and Phase
gates - then you can write an efficient synthesis of multi-controlled RZX
by calling mcx
, mcrx
, mcry
, mcrz
and mcp
.
Environment
What is happening?
Running the below code results in the exception copied in the "What should happen" section. I would expect the code to run without error.
This crash happens for num_ctrl_qubits>=9. For num_ctrl_qubits<9, the program hangs for a long time and I need to kill the process.
How can we reproduce the issue?
What should happen?
Any suggestions?
No response