Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for isolated nodes when running RQAOA #157

Merged
merged 10 commits into from
Jan 13, 2023

Conversation

kidiki
Copy link
Contributor

@kidiki kidiki commented Dec 23, 2022

Description

Bug fix for isolated nodes when running RQAOA

  • Fixes # (issue)
    For solving the MaxCut problem on unweighted graphs the isolated nodes were not captured and fixed arbitrarily for some particular instances. As a result, the elimination schedule was missing one of the eliminations and throwing an error "list out of range" when reconstructing the solution.

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

  • I have performed a self-review of my code.
  • I have commented my code and used numpy-style docstrings
  • I have made corresponding updates to the documentation.
  • My changes generate no new warnings
  • I have added/updated tests to make sure bugfix/feature works.
  • New and existing unit tests pass locally with my changes.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

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

…in map and checking if the diff between the old and new registers mactches the number of eliminations
@codecov
Copy link

codecov bot commented Dec 23, 2022

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%) ⬇️
openqaoa/qaoa_parameters/gatemap.py 89.03% <ø> (ø)
openqaoa/qaoa_parameters/hamiltonianmapper.py 100.00% <ø> (ø)
openqaoa/workflows/optimizer.py 94.07% <99.17%> (+3.53%) ⬆️
tests/test_workflows.py 99.82% <99.50%> (-0.18%) ⬇️
openqaoa/backends/qpus/qaoa_pyquil_qpu.py 93.02% <100.00%> (+0.16%) ⬆️
openqaoa/backends/simulators/qaoa_pyquil_sim.py 86.27% <100.00%> (+0.56%) ⬆️
openqaoa/backends/simulators/qaoa_qiskit_sim.py 100.00% <100.00%> (ø)
openqaoa/backends/simulators/qaoa_vectorized.py 95.02% <100.00%> (+0.04%) ⬆️
openqaoa/optimizers/result.py 93.63% <100.00%> (+1.88%) ⬆️
... and 20 more

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

@kidiki
Copy link
Contributor Author

kidiki commented Dec 23, 2022

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

@kidiki kidiki marked this pull request as ready for review December 23, 2022 08:14
@Q-lds
Copy link
Member

Q-lds commented Dec 27, 2022

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

@Q-lds
Copy link
Member

Q-lds commented Dec 27, 2022

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
Copy link
Member

Q-lds commented Dec 27, 2022

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

@Q-lds Q-lds assigned Q-lds and kidiki and unassigned Q-lds Jan 4, 2023
@Q-lds Q-lds added the bug Something isn't working label Jan 4, 2023
@vishal-ph vishal-ph merged commit be5a520 into dev Jan 13, 2023
@vishal-ph vishal-ph deleted the dev-bugfix-rqaoa-isolated-spins branch January 13, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants