Hi all,
I’m wondering if there has been support for the qml.to_openqasm() function for multi-controlled operations, including inverse QFT and PauliZ. It seems that for >=3-controlled inverse QFT operation, or >=4-controlled PauliZ cannot be converted.
import pennylane as qml
dev = qml.device("default.qubit", wires=6)
@qml.qnode(dev)
def circuit():
for wire in range(3):
qml.Hadamard(wires=wire)
qml.ctrl(qml.QFT, control=[3, 4, 5])(wires=range(3))
qml.ctrl(qml.PhaseAdder, control=[3, 4, 5])(k=1, x_wires=range(3))
# qml.ctrl(qml.adjoint(qml.QFT), control=[3, 4, 5])(wires=range(3))
# qml.ctrl(qml.PauliZ, control=[1, 2, 3, 4, 5])(wires=0)
return qml.probs(wires=range(3))
qml.draw_mpl(circuit, style='pennylane', wire_order=[0, 1, 2, 3, 4, 5])()
t = qml.to_openqasm(circuit, measure_all=False)()
The code above runs fine, until you uncomment any of two qml.ctrl() lines. Both yield the following error
ValueError: Operation GlobalPhase not supported by the QASM serializer
As I dig around, it seems QFT utilizes the ControlledPhaseShift() operation, which is decomposed to some qml.GlobalPhase() gates that cannot be parsed to openqasm. Is there a way we can use the qml.transforms.combine_global_phase() and then remove the combined global phase, or would there be another workaround this?
Here’s my qml.about():
Version: 0.42.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page:
Author:
Author-email:
License-Expression: Apache-2.0
Location: (omitted)
Requires: (omitted)
Required-by: PennyLane-Cirq, PennyLane-qiskit, pennylane_lightning
Platform info: Windows-10 (omitted)
Python version: 3.11.9
Numpy version: 2.3.0
Scipy version: 1.15.3
Installed devices:
- default.clifford (pennylane-0.42.0)
- default.gaussian (pennylane-0.42.0)
- default.mixed (pennylane-0.42.0)
- default.qubit (pennylane-0.42.0)
- default.qutrit (pennylane-0.42.0)
- default.qutrit.mixed (pennylane-0.42.0)
- default.tensor (pennylane-0.42.0)
- null.qubit (pennylane-0.42.0)
- reference.qubit (pennylane-0.42.0)
- cirq.mixedsimulator (PennyLane-Cirq-0.41.0)
- cirq.pasqal (PennyLane-Cirq-0.41.0)
- cirq.qsim (PennyLane-Cirq-0.41.0)
- cirq.qsimh (PennyLane-Cirq-0.41.0)
- cirq.simulator (PennyLane-Cirq-0.41.0)
- lightning.qubit (pennylane_lightning-0.42.0)
- qiskit.aer (PennyLane-qiskit-0.42.0)
- qiskit.basicaer (PennyLane-qiskit-0.42.0)
- qiskit.basicsim (PennyLane-qiskit-0.42.0)
- qiskit.remote (PennyLane-qiskit-0.42.0)
Thanks for your help!