Closed BrunoRosendo closed 3 months ago
I found quite useful information on slack. One way to possibly fix this:
To the original poster. As QAOA does not allow you to pass an ansatz, which should be a transpiled circuit now, one thing you could use instead is SamplingVQE with the QAOAAnsatz from the Qiskit circuit library (which is what QAOA does as its just a simple sub-class of SamplingVQE). You would need to have the operator - to set number of qubits for the circuit - lets gets to that. To get the operator you would have to create the problem and convert it to_ising yourself so you have the operator you can use directly with the algorithm. Ie you would not be using MinimumEigenOptimizer which does this for you. With the operator you can get its num_qubits and set the QAOAAnsatz up and then transpile it. That gets the circuit part. The next bit would be to make sure the operator (observable) matches the transpiled circuit using apply_layout. If you look at the second link in my post above you will find that in the first Estimator example. Once you have the result of the algorithm you can interpret it in the context of the original problem. You can look at the code in MinimumEigenOptimizer for an example. I knew this ISA requirement for real devices - I was not aware of it being done for simulators though. The other choice would be to install Qiskit Aer and run this locally via an Aer Primitive on your machine as the ISA requirement is for IBM Runtime.
Thanks Steve, that's really useful. Just for others' reference, I found an alternative way which involves converting the QuadraticProgram to an Ising, applying the layout, and converting it back into a QuadraticProgram, which means the MinimumEigenOptimizer can still be used
This slack thread has additional doubts that might arise https://qiskit.slack.com/archives/C7SS31917/p1713377308386869
Something like this is likely necessary hamiltonian_isa = hamiltonian.apply_layout(layout=ansatz_isa.layout)
The problem is solved on my fork https://github.com/BrunoRosendo/qiskit-algorithms, although this only works for minimum eigen value case. The reason for this is the fix only works for SparsePauliOp, while SamplingVQE supports all kinds of BaseOperator
I tested in IBM runtime with and without warm start. The Queue is currently very long so I'll wait a bit to complete #44
This issue came up in #44, and it's related to an update made recently by IBM (March 2024): https://docs.quantum.ibm.com/run/primitives-examples
The issue was created 1 month ago without much track https://github.com/qiskit-community/qiskit-algorithms/issues/164 . I have commented on it and I saw more people complain about the same issue on slack. This happens not only on qiskit-algorithms but also other libraries, such as qiskit-machine-learning and qiskit-optimization.
The problem does not happen when using BackendSampler instead of SamplerV1 of qiskit-ibm-runtime. SamplerV2 is not yet supported by the library. The problem with using BackendSampler is the lack of sessions, making it unfeasible to run the algorithms (check #44 for details).
Based on the announcement and the thread below, I tried transpiling the ansatz and adding a padding to the operator (observable) as to match the number of qubits in the backend. However, I can't find a way to add the padding. Even if I did, I think there would be more problems. I made a fork with that approach, used in feature/qaoa-fork
https://quantumcomputing.stackexchange.com/questions/29332/how-to-avoid-delays-must-be-a-multiple-of-16-samples-error-with-estimator-sa
For now, I'm going to wait for a potential fix on qiskit's part. If that doesn't happen, I will try once again to fix their library