Closed woodsp-ibm closed 2 years ago
I confirm the code works with Qiskit 0.27, but does not with 0.28. The problem is introduced here: https://github.com/Qiskit/qiskit-terra/pull/6396. Now the number of parameters in QAOAAnsatz
computed incorrectly and the beta
parameter has only one value for all reps
. @Cryoris please confirm.
I tried the script in https://github.com/Qiskit/qiskit-optimization/issues/210#issue-951099960 with qiskit-optimization main and https://github.com/Qiskit/qiskit-terra/pull/6828. It works as follows.
Using reps 2 with initial point [0, 0, 1, 1]
optimal function value: 35.0
optimal value: [0. 1. 0. 1. 0.]
status: SUCCESS
@t-imamichi could you please also check, if all beta values are set correctly? i'm not sure if that the parameter beta here: WarmStartQAOAFactory is considered in the PR you mentioned. Thanks!
I executed the same code https://github.com/Qiskit/qiskit-optimization/issues/210#issuecomment-892663105 with the main branch and it generated the same output. I don't know what are the expected values for beta, but, I see the dimension matches and the code runs without any error.
Because https://github.com/Qiskit/qiskit-terra/pull/6828 is merged, I think this issue is fixed. This is the output in my environment with the latest terra and opt.
Using reps 2 with initial point [0, 0, 1, 1]
/Users/ima/tasks/1_2021/qiskit/terra/qiskit/opflow/primitive_ops/pauli_sum_op.py:362: DeprecationWarning: The SparsePauliOp.table method is deprecated as of Qiskit Terra 0.19.0 and will be removed no sooner than 3 months after the releasedate. Use SparsePauliOp.paulis method instead.
tables = self.primitive.table
optimal function value: 35.0
optimal value: [0. 1. 0. 1. 0.]
status: SUCCESS
The issue was originally raised on Qiskit Slack #aqua channel here
The following code sample, based on what was provided in that discussion, works at reps=1 (or at least it does for me but gave the originator of the message this error
ValueError: array must not contain infs or NaNs
that I could not reproduce). At reps > 1 then it fails with an error like thisbut was stated that it worked on prior version (I did not check).
I will note that if initial_point is set to None (a line in the sample code does that but is commented out so it will fail at present) then things work fine.
Also if you run qaoa itself it proves the initial_point is being passed in correctly in terms of at least an initial length that matches. And you then go onto re-use the same qaoa instance for the WarmStart algo, it works fine (the block with the do_qaoa that is set False at present again so it the sample will fail).
I will note I reduced SPSA max_iter down from the 500 of the original sample to 5 just for testing whether it failed or not.