Dumping IsingZZ to qasm2 then loading the qasm2 file doesn't work

When I try qiskit.qasm2.dumps(circuit) with qml.IsingZZ in it, then reload the circuit using qml.from_qasm(circuit_qasm) there is an error message

qiskit.qasm2.exceptions.QASM2ParseError: "<input>:10,0: 'rzz' is not defined in this scope"

Can you please help with this issue?

Installed pennylane:

Name: PennyLane
Version: 0.37.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: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /home/cuquantum/conda/envs/cuquantum-23.10/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-qiskit, PennyLane_Lightning, PennyLane_Lightning_GPU

Platform info:           Linux-6.5.0-1017-azure-x86_64-with-glibc2.35
Python version:          3.10.13
Numpy version:           1.26.4
Scipy version:           1.14.0
Installed devices:
- lightning.qubit (PennyLane_Lightning-0.37.0)
- default.clifford (PennyLane-0.37.0)
- default.gaussian (PennyLane-0.37.0)
- default.mixed (PennyLane-0.37.0)
- default.qubit (PennyLane-0.37.0)
- default.qubit.autograd (PennyLane-0.37.0)
- default.qubit.jax (PennyLane-0.37.0)
- default.qubit.legacy (PennyLane-0.37.0)
- default.qubit.tf (PennyLane-0.37.0)
- default.qubit.torch (PennyLane-0.37.0)
- default.qutrit (PennyLane-0.37.0)
- default.qutrit.mixed (PennyLane-0.37.0)
- default.tensor (PennyLane-0.37.0)
- null.qubit (PennyLane-0.37.0)
- qiskit.aer (PennyLane-qiskit-0.37.0)
- qiskit.basicaer (PennyLane-qiskit-0.37.0)
- qiskit.basicsim (PennyLane-qiskit-0.37.0)
- qiskit.ibmq (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.37.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.37.0)
- qiskit.remote (PennyLane-qiskit-0.37.0)
- lightning.gpu (PennyLane_Lightning_GPU-0.37.0)
1 Like

Hi @Hovnatan_Karapetyan,

Thank you for your question.

Could you please share a minimal reproducible example so that we can look for the root of the problem? A minimal reproducible example (or minimal working example) is the simplest version of the code that reproduces the problem. It should be self-contained, including all necessary imports, data, functions, etc., so that we can copy-paste the code and reproduce the problem. However it shouldn’t contain any unnecessary data, functions, …, for example gates and functions that can be removed to simplify the code.

Also, please post your full error traceback. If you’re not sure what this means then please make sure to check out this video.

On the other hand, please upgrade to our latest version of PennyLane (v0.38 at the moment) and let us know if the issue persists with the new version.
Thanks!

Hi @CatalinaAlbornoz ,

Here is a minimal reproducible example. The last line throws an error. Let me know if I am doing the pennylane to qasm2 conversion wrong. Thanks!

import pennylane as qml
import qiskit
from qiskit_aer import AerSimulator

dev_qiskit = qml.device(
    "qiskit.aer",
    wires=2,
    backend=AerSimulator(method="statevector"),
    shots=None,
)


def circuit(params):
    qml.RX(params[0], wires=0)
    qml.IsingZZ(params[1], wires=[0, 1])

    return qml.state()


cn = qml.QNode(circuit, dev_qiskit)
cn([0.1, 0.2])
qasm2_string = qiskit.qasm2.dumps(dev_qiskit._circuit)  # noqa: SLF001

print(qasm2_string)

loaded_circuit = qml.from_qasm(qasm2_string)

Thanks @Hovnatan_Karapetyan !

I think this might be related to this issue on the Qiskit repo which has been open since January. They propose a workaround that you could try. I get a different error than you do so I’m unable to replicate your error at the moment.

I hope this helps though!