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

Symbolic Hamiltonian fixes #312

Merged
merged 5 commits into from
Jan 28, 2021
Merged

Symbolic Hamiltonian fixes #312

merged 5 commits into from
Jan 28, 2021

Conversation

scarrazza
Copy link
Member

Following the discussion in #311, this PR:

  • moves the SymbolicHamiltonian to core
  • uses K.numeric_types to intercept scalar symbols
  • fixes the Trotter from symbolic expression.

@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #312 (dbfbd6b) into maxcut (e3628a2) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           maxcut     #312      +/-   ##
==========================================
+ Coverage   99.84%   99.96%   +0.12%     
==========================================
  Files          59       59              
  Lines       11312    11329      +17     
==========================================
+ Hits        11294    11325      +31     
+ Misses         18        4      -14     
Flag Coverage Δ
unittests 99.96% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/qibo/abstractions/hamiltonians.py 100.00% <ø> (+0.33%) ⬆️
src/qibo/core/hamiltonians.py 100.00% <100.00%> (ø)
src/qibo/tests/test_hamiltonians.py 100.00% <100.00%> (ø)
src/qibo/hamiltonians.py 94.44% <0.00%> (+18.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3628a2...dbfbd6b. Read the comment docs.

@scarrazza
Copy link
Member Author

@stavros11 I think the fix for the trotter may not be working well (see test failure), could you please have a look?

constant = self.constant
if set(len(t) for t in terms.keys()) == {1, 2}:
terms = self.merge_one_qubit(terms)
return terms, self.constant
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, the issue is here:

Suggested change
return terms, self.constant
return terms, constant

Note that even after this fix there are some numerical issues with the Trotter of the MaxCut and we should set for example atol=1e-12 to make this test pass. This is probably because the construction of the terms within the Trotter introduces a small numerical error and some values that should be 0 become 1e-16. I don't think it is due to a bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this works.

@scarrazza scarrazza merged commit 31ba258 into maxcut Jan 28, 2021
@scarrazza scarrazza deleted the fixsymbolictrotter branch February 6, 2021 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants