I have a complex Integer Linear Programming model defined in DOcplex/Qiskit representing a combinatorial optimization problem.

Using the Qiskit utils, it is possible to covert it to either an Ising model or Pauli operators.

For a particular reason, I need to use Pennylane’s QAOA to solve the problem. Is there any easy way to convert the Qiskit’s Ising model/Pauli operators output to something that Pennylane “understands”?

I can neither find something in the Pennylane documentation mor can I a find sth. like DOcplex or any other QUBO-related tools in the Pennylane ecosystem.

  • $\begingroup$ Why do you need to use Pennylane? $\endgroup$ Dec 16, 2021 at 20:55

1 Answer 1


This is Catalina from Xanadu. I don't think there's a converter as you describe it, but in PennyLane you can load a circuit in Qiskit format. You just create your circuit with qiskit syntax and use qml.load(qc, format='qiskit') to convert it into a PennyLane template. You can then use it within a PennyLane circuit. The example below should help.

import pennylane as qml
from pennylane import numpy as np
import qiskit
from qiskit.circuit import Parameter

qc = qiskit.QuantumCircuit(2)
theta = Parameter("θ")

qc.rx(theta, [0])
qc.cx(0, 1)

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

dev = qml.device('default.qubit', wires=2)

def circuit(x):
    my_circuit(params={theta: x},wires=(1, 0))
    return qml.expval(qml.PauliZ(0))

theta_train = np.array(1.5, requires_grad=True)

opt = qml.GradientDescentOptimizer()

for i in range(1000):
    theta_train = opt.step(circuit, theta_train)
    if i % 100 == 0:
        print("Cost", circuit(theta_train))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.