Closed Thevendran closed 4 months ago
Hi @Thevendran. I was able to successfully run your code on a simulator backend. ~The Rigetti device is not available right now, so I plan to try reproducing the error on OQC tomorrow.~ Edit: I can repro without device availability. I'm looking into it.
For the record, here is the code I ran:
from qiskit.primitives import BackendSampler
from qiskit_algorithms.minimum_eigensolvers import QAOA
from qiskit_algorithms.optimizers import COBYLA
from qiskit_optimization.algorithms import MinimumEigenOptimizer
from qiskit_optimization.problems import QuadraticProgram
from qiskit_optimization.translators import from_docplex_mp
from qiskit_braket_provider import AWSBraketProvider, BraketLocalBackend
from docplex.mp.model import Model
mdl = Model("docplex model")
x0 = mdl.binary_var("x0")
x1 = mdl.binary_var("x1")
x2 = mdl.binary_var("x2")
mdl.minimize(-30*x0**2 + 14*x0*x1 + 14*x0*x2 - 35*x1**2 + 14*x1*x2 - 29*x2**2)
mod = from_docplex_mp(mdl)
sampler = BackendSampler(
# backend=AWSBraketProvider().get_backend("Lucy"),
backend=BraketLocalBackend(),
skip_transpilation=False,
options={"shots": 100}
)
qaoa = QAOA(sampler=sampler, optimizer=COBYLA())
qaoa_solver = MinimumEigenOptimizer(qaoa)
result = qaoa_solver.solve(mod)
with the local backend, result
gives: <MinimumEigenOptimizationResult: fval=-52.0, x0=1.0, x1=1.0, x2=1.0, status=SUCCESS>
.
I was able to reproduce the first issue. There seems to be a bug in convert_qiskit_to_braket_circuit
. I will open a new issue for it. For the time being, this branch should help you get around this problem: https://github.com/laurencap/qiskit-braket-provider/tree/bugfix/convert-qiskit-to-braket-measurements If you need any help getting set up with a local installation off that branch, let me know.
I wasn't able to reproduce the second issue. Can you share the backtrace as well as your version information for the Python packages you are using?
@Thevendran using the branch of qiskit-braket-provider
mentioned by @laurencap above, I see that the second issue you mention seems to be working successfully. When using BraketLocalBackend to run the program, I get a result of:
<MinimumEigenOptimizationResult: fval=-118.0, x0=0.0, x1=1.0, x2=1.0, x3=0.0, x4=0.0, x5=1.0, x6=1.0, x7=0.0, x8=0.0, x9=0.0, status=SUCCESS>
If you are still having this issue, could you please share the full code snippet that reproduces the problem, the full error output (including backtrace), and the output of pip list
?
Hi @Thevendran , I also couldn't reproduce the second issue. With qiskit-braket-provider==0.0.5
, the second larger quadratic function throws error ValueError: Observable's qubit count 1 and the size of the target qubit set QubitSet([Qubit(40), Qubit(0)]) must be equal
, which can be solved by the PR created by @laurencap. As mentioned, if the issue persists for you, full code to reproduce the issue (including the imports) and the output of pip list
would be helpful for debugging.
Closing at the first issue must have been fixed by #135 and there is not enough information to find the root cause for the second issue. The recent code changes (filtering QPU gatesets) might be helping. Please reopen this issue if you still run into these issues.
Hi.
I am facing issues in running QAOA algorithm against Rigetti backend. Following is the optimization code that I am using.
sampler = BackendSampler( backend=AWSBraketProvider().get_backend("Aspen-M-3"), skip_transpilation=False, options={"shots": 100} ) qaoa = QAOA(sampler=sampler, optimizer=COBYLA()) qaoa_solver = MinimumEigenOptimizer(qaoa) result = qaoa_solver.solve(qp)
I am facing the following 2 issues:
Issue #1 When the number of binary variables is more than 2, I am getting the following error:
Observable's qubit count 1 and the size of the target qubit set QubitSet([Qubit(4), Qubit(0)]) must be equal
Example quadratic function that triggered the issue :
Minimize -30*x0^2 + 14*x0*x1 + 14*x0*x2 - 35*x1^2 + 14*x1*x2 - 29*x2^2
Issue #2 As the number of binary variables increases gradually (for ex. 10 variables), I am getting the following different error:
QiskitError: "Cannot unroll the circuit to the given basis, dict_keys(['measure', 'cz', 'cx', 'cp', 'h', 'id', 'p', 'rx', 'ry', 'rz', 's', 'sdg', 'swap', 't', 'tdg', 'x', 'y', 'z']). Instruction measure not found in equivalence library and no rule found to expand."
Example quadratic function that triggered the issue:
Minimize -36*x0^2 + 16*x0*x1 + 16*x0*x2 + 16*x0*x3 + 16*x0*x4 + 16*x0*x5 + 16*x0*x6 - 41*x1^2 + 16*x1*x2 + 16*x1*x3 + 16*x1*x4 + 16*x1*x7 + 16*x1*x8 - 43*x2^2 + 16*x2*x3 + 16*x2*x5 + 16*x2*x7 + 16*x2*x9 - 42*x3^2 + 16*x3*x6 + 16*x3*x8 + 16*x3*x9 - 35*x4^2 + 16*x4*x5 + 16*x4*x6 + 16*x4*x7 + 16*x4*x8 - 42*x5^2 + 16*x5*x6 + 16*x5*x7 + 16*x5*x9 - 40*x6^2 + 16*x6*x8 + 16*x6*x9 - 40*x7^2 + 16*x7*x8 + 16*x7*x9 - 35*x8^2 + 16*x8*x9 - 41*x9^2
Please help suggest a solution.