Load parametrized Qiskit Instructions that act on multiple qubits

Hello Forum,

I have a Problem with the qml.load function when using parametrized instructions in the qiskit circuit to load. It is all fine when the instruction only acts on a single qubit, but for an instruction on multiple qubits i receive an error message:

theta = Parameter('θ')

qc = QuantumCircuit(2)

qc.rzz(theta,0,1)
# this works:
# qc.rz(theta, 0)

plqc = qml.load(qc, format='qiskit')

dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev)
def circuit(x):
    plqc(params={theta:x})
    return qml.state()

circuit(3)

This results in the following Exception:

TypeError: ParameterExpression with unbound parameters ({Parameter(θ)}) cannot be cast to a float.

Is there a way around this somehow?
Thank you for your help!

Sounds to me like your qiskit-terra is backlevel.
Have you tried pip install -U qiskit-terra ?

Hi @Johannes,

Thanks for pointing out this behaviour we will take a look at it and come back to you.

Hello @Jack_W,

Thanks for your reply. Indeed my qiskit-terra version was backlevel. But after the upgrade the error still occurcs.

When I test my versions via qiskit.qiskit_version , I get the following:

{‘qiskit-terra’: ‘0.20.0’, ‘qiskit-aer’: ‘0.10.4’, ‘qiskit-ignis’: ‘0.7.0’, ‘qiskit-ibmq-provider’: ‘0.19.0’, ‘qiskit-aqua’: None, ‘qiskit’: ‘0.36.0’, ‘qiskit-nature’: None, ‘qiskit-finance’: None, ‘qiskit-optimization’: None, ‘qiskit-machine-learning’: None}

1 Like

Hi @Johannes,

One of my colleagues found the root of the problem. RZZ was not supported by PennyLane so it falls back to transforming it to a matrix. This is not possible with symbolic parameters so that’s why you were getting an error.

We have now added support for RZZ so if you upgrade the pennylane-qiskit plugin it should work now!

Thank you for posting this question. Enjoy using PennyLane!

4 Likes

Hello @CatalinaAlbornoz,

Thank you for your help, it works now!

1 Like