-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improvements to expectation_from_samples code #59
Conversation
Eventually want to have some shot allocation for each term in the Hamiltonian Currently, the code is s.t. `n_shots` is allocated for every single term in the Hamiltonian
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 12 +1
Lines 433 494 +61
=========================================
+ Hits 433 494 +61
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
For a uniform distribution of shots
- Move code and functions that aim to reduce and optimize the measurement cost into a new file (`optimization.py`) - `expectation.py` is now more focused: Only code for obtaining the Hamiltonian expectation value left in there
np.array.as_type(int) truncates the array, so there shouldn't be a need to handle the case if too many shots were allocated...? - Note: Was observed quite long ago in local testing of an earlier version of code, but don't remember how I got it? - Might be that the changes to the earlier code removed the possibility of this happening?
Came about due to working on the ucc_ansatz and mol-updates branches separately
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 12 +1
Lines 433 495 +62
=========================================
+ Hits 433 495 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Currently, if
from_samples=True
in ourexpectation
function,n_shots
is effectively allocated to each and every term in the Hamiltonian.This pull request aims to improve upon this by adding the functionality to manually allocate shots to the individual terms in the Hamiltonian.
Note: This should (hopefully) allow the implementation of some measurement reduction schemes as well...? But that's probably beyond the scope of this pull request.
(25 Jan edit): Code and tests are tentatively done, left with documentation