# Pennylane to Qiskit

**URL:** <https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204>\
**Category:** PennyLane Qiskit\
**Created:** [October 5, 2022, 7:02am UTC](https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204 "2022-10-05T07:02:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mass\_of\_15](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mass_of_15/32/1430_2.png) [@mass\_of\_15](https://discuss.pennylane.ai/u/mass_of_15)\
**Post date:** [October 5, 2022, 7:02am UTC](https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204/1 "2022-10-05T07:02:51Z")

</div>

Hey, I want to convert my pennylane code to qiskit. Can anyone help me in this regard?

This is the code:

> wires=4  
> dev4 = qml.device(“defaults.qubit”, wires=wires) # define the simulator  
> @qml.qnode(dev4)  
> def CONVCircuit(phi, wires, i=0):  
> “”"  
> quantum convolution Node  
> “”"  
> # parameter  
> theta = np.pi / 2  
> qml.RX(phi[0] \* np.pi, wires=0)  
> qml.RX(phi[1] \* np.pi, wires=1)  
> qml.RX(phi[2] \* np.pi, wires=2)  
> qml.RX(phi[3] \* np.pi, wires=3)  
> qml.CRZ(theta, wires=[1, 0])  
> qml.CNOT(wires=[0, 1])  
> qml.CRZ(theta, wires=[3, 2])  
> qml.CNOT(wires=[2, 3])  
> qml.CRX(theta, wires=[1, 0])  
> qml.CNOT(wires=[0, 1])  
> qml.CRX(theta, wires=[3, 2])  
> qml.CNOT(wires=[2, 3])  
> qml.CRZ(theta, wires=[2, 0])  
> qml.CNOT(wires=[0, 2])  
> qml.CRX(theta, wires=[2, 0])  
> qml.CNOT(wires=[0, 2])

```
# Expectation value
measurement = qml.expval(qml.PauliZ(wires=0))
return measurement

```

Please look into this.

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [October 6, 2022, 1:47am UTC](https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204/2 "2022-10-06T01:47:47Z")

</div>

Hi @mass_of_15, welcome to the forum!

You could try converting your code to Open QASM using the `to_openqasm` function. Then you can load it in Qiskit. You may need to remove the measurement because I’m not sure that it will work with Qiskit.

You can take a look at the thread [here](http://discuss.pennylane.ai/t/how-can-i-save-the-quantum-circuit-into-disk-and-load-from-disk-in-pennylane/2195/2) for an example on how to convert your circuit to Open QASM.

Does this work for you?

---

<div class="post-metadata">

**Author:** ![NotSchrodinger](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/notschrodinger/32/2133_2.png) [@NotSchrodinger](https://discuss.pennylane.ai/u/NotSchrodinger)\
**Post date:** [November 27, 2023, 6:57am UTC](https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204/3 "2023-11-27T06:57:14Z")

</div>

Hi! I was searching a similar functionality to convert qml code to Qiskit. Just want to confirm that conversion Pennylane-\>QASM-\>Qiskit is still the only option?

Thanks!

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [November 29, 2023, 2:52am UTC](https://discuss.pennylane.ai/t/pennylane-to-qiskit/2204/4 "2023-11-29T02:52:21Z")

</div>

Hi @NotSchrodinger, welcome to the Forum!

That is indeed the only option at the moment. You can tell us more about your problem to see if there’s an alternate solution. For example, if you want to run your code on IBM hardware or simulators you can do it directly from PennyLane.

Also, we have a very small survey for [PennyLane v0.33](https://bit.ly/PennyLane-v033-survey), and it would be awesome if you’d give us some feedback and tell us about your needs. Thank you! 😁
