entropicalabs / openqaoa

Multi-backend SDK for quantum optimisation
MIT License
119 stars 59 forks source link

Bug fix for isolated nodes when running RQAOA #157

Closed kidiki closed 1 year ago

kidiki commented 1 year ago

Description

Bug fix for isolated nodes when running RQAOA

The current solution is to keep track of the number of eliminations which have to take place at each step reconstructing them from the spin map. Then, comparing the new register either to the quadratic one, a s before, or to the old one - number of eliminations.

Checklist

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Name the new unit-tests that you have added along with this change.

codecov[bot] commented 1 year ago

Codecov Report

Merging #157 (13f8f4d) into dev (435f400) will increase coverage by 1.00%. The diff coverage is 99.69%.

@@            Coverage Diff             @@
##              dev     #157      +/-   ##
==========================================
+ Coverage   80.69%   81.70%   +1.00%     
==========================================
  Files          94       95       +1     
  Lines       11393    11794     +401     
==========================================
+ Hits         9194     9636     +442     
+ Misses       2199     2158      -41     
Impacted Files Coverage Δ
openqaoa/problems/helper_functions.py 90.00% <ø> (-0.63%) :arrow_down:
openqaoa/qaoa_parameters/gatemap.py 89.03% <ø> (ø)
openqaoa/qaoa_parameters/hamiltonianmapper.py 100.00% <ø> (ø)
openqaoa/workflows/optimizer.py 94.07% <99.17%> (+3.53%) :arrow_up:
tests/test_workflows.py 99.82% <99.50%> (-0.18%) :arrow_down:
openqaoa/backends/qpus/qaoa_pyquil_qpu.py 93.02% <100.00%> (+0.16%) :arrow_up:
openqaoa/backends/simulators/qaoa_pyquil_sim.py 86.27% <100.00%> (+0.56%) :arrow_up:
openqaoa/backends/simulators/qaoa_qiskit_sim.py 100.00% <100.00%> (ø)
openqaoa/backends/simulators/qaoa_vectorized.py 95.02% <100.00%> (+0.04%) :arrow_up:
openqaoa/optimizers/result.py 93.63% <100.00%> (+1.88%) :arrow_up:
... and 20 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

kidiki commented 1 year ago

The failed tests are assertion errors for the angles with precision 10^-16. Is this really necessary?

Q-lds commented 1 year ago

Why all those tests? Did you issue a PR to main and then change it to dev

Q-lds commented 1 year ago

Also, it is very interesting that the tests are all green for Linux but consistently fail for all mac/windows. It must be something to do with different ways of rounding numbers across different OS

Q-lds commented 1 year ago

and @kidiki it looks like the errors are a bit larger:

FAILED tests/test_results.py::TestingRQAOAResultOutputs::test_rqaoa_result_methods_steps - AssertionError: Optimized angles are not correct
assert [0.3386847452...0316893752504] == [0.3404859432...5304635645852]
  At index 0 diff: 0.3386847452289164 != 0.34048594327263326

see https://github.com/entropicalabs/openqaoa/actions/runs/3764081183/jobs/6398159774#step:6:363