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

Modularize DDD functionality #2610

Merged
merged 5 commits into from
Dec 20, 2024
Merged

Conversation

bdg221
Copy link
Collaborator

@bdg221 bdg221 commented Dec 20, 2024

Description


This PR introduces two functions

  • generate_circuits_with_ddd
  • generate_ddd_value

for generating circuits with DDD sequences and using the results from running those circuits to get an expectation value. The first function moves generating the circuits outside of execute_with_ddd, allowing users to generate and return DDD circuits.

The second function takes the results from all of the DDD circuits used in execute_with_ddd and averages the results to produce a single expectation value (float) that is returned.

fixes #2562

@bdg221 bdg221 requested a review from natestemen December 20, 2024 15:50
@bdg221 bdg221 self-assigned this Dec 20, 2024
@bdg221
Copy link
Collaborator Author

bdg221 commented Dec 20, 2024

@natestemen Do you think the second function generate_ddd_value is necessary since it is just calling np.average? The reason for adding it is due to ZNE and PEC modularization handling generate circuits and generating results.

@bdg221
Copy link
Collaborator Author

bdg221 commented Dec 20, 2024

On the community call, it was agreed that the second function is important for consistency with ZNE and PEC. Also, I changed generate_ddd_value to combine_results for consistency.

Copy link
Member

@natestemen natestemen left a comment

Choose a reason for hiding this comment

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

LGTM! Left one comment, and my only other hold-up was thinking generate_circuits_with_ddd is a bit of a mouthful, but I can't think of a better name!

@@ -226,3 +231,14 @@ def exec_xx_small_spacing(circuit):
# What is important to test is getting different results.
assert not np.isclose(unmitigated, mitigated_small_spacing)
assert not np.isclose(mitigated_large_spacing, mitigated_small_spacing)


@mark.parametrize("num_trials", [1, 3, 5])
Copy link
Member

Choose a reason for hiding this comment

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

Since this test should be fast (correct me if i'm wrong) can we add a few more trials? Say up to 30?

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.73%. Comparing base (1370ee9) to head (048c925).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2610   +/-   ##
=======================================
  Coverage   98.73%   98.73%           
=======================================
  Files          92       92           
  Lines        4176     4198   +22     
=======================================
+ Hits         4123     4145   +22     
  Misses         53       53           

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

@natestemen
Copy link
Member

Going to merge before CI passes. I ran the new test locally and it looks good!

@natestemen natestemen merged commit 5a025af into unitaryfund:main Dec 20, 2024
13 of 14 checks passed
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.

Modularize DDD
2 participants