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

Improvements to expectation_from_samples code #59

Merged
merged 24 commits into from
Feb 19, 2024

Conversation

chmwzc
Copy link
Contributor

@chmwzc chmwzc commented Dec 13, 2023

Currently, if from_samples=True in our expectation 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

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
@chmwzc chmwzc self-assigned this Dec 13, 2023
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ad1277b) 100.00% compared to head (a1ba3ed) 100.00%.
Report is 9 commits behind head on main.

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chmwzc chmwzc added this to the Qibochem 0.0.2 milestone Jan 24, 2024
@chmwzc chmwzc added enhancement New feature or request documentation Improvements or additions to documentation labels Jan 24, 2024
- 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?
@chmwzc chmwzc marked this pull request as ready for review January 31, 2024 02:21
Came about due to working on the ucc_ansatz and mol-updates branches separately
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b6f614d) 100.00% compared to head (85e9b27) 100.00%.
Report is 2 commits behind head on main.

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@damarkian damarkian merged commit 4c093bf into main Feb 19, 2024
5 checks passed
@damarkian damarkian deleted the expectation-from-samples branch February 19, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants