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

LRE failure for chunking #2608

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

LRE failure for chunking #2608

wants to merge 4 commits into from

Conversation

purva-thakre
Copy link
Collaborator

@purva-thakre purva-thakre commented Dec 20, 2024

Description

Noticed in #2601

https://github.com/unitaryfund/mitiq/actions/runs/12433520415/job/34715234002?pr=2601#step:6:4591

Originally, the test was written to confirm chunking a circuit performs worse in certain scenarios. However, this performance varies non-deterministically. Due to this reason, now the test is verifying there is a difference between two expectation values.


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.74%. Comparing base (2dc8c4f) to head (3021921).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2608   +/-   ##
=======================================
  Coverage   98.73%   98.74%           
=======================================
  Files          92       93    +1     
  Lines        4193     4219   +26     
=======================================
+ Hits         4140     4166   +26     
  Misses         53       53           

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

@purva-thakre
Copy link
Collaborator Author

Converting this back to draft because @natestemen suggested to write a better test.

@purva-thakre purva-thakre marked this pull request as draft December 20, 2024 19:19
@purva-thakre purva-thakre marked this pull request as ready for review January 14, 2025 18:32
@purva-thakre purva-thakre removed the request for review from cosenal January 14, 2025 18:32
assert abs(lre_exp_val - ideal_val) <= abs(noisy_val - ideal_val)
# verify we get an expectation value
assert(lre_exp_val_chunking) > 0

Copy link
Collaborator Author

@purva-thakre purva-thakre Jan 14, 2025

Choose a reason for hiding this comment

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

@natestemen I cannot think of a better test here. Which is why I decided to check the function does provided a non-zero expectation value.

test_layerwise_folding already has a test comparing the number of noise-scaled layers for a chunked and a non-chunked circuit.

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.

I would argue that this test is unnecessary.

We already have tests that ensure that chunking works as expected (here, and here). The only thing this test could be doing (aside from asserting accuracy) is testing the number of circuits run is as expected, but this would be redundant from the above linked tests.

Should we remove it. WDYT?

@purva-thakre
Copy link
Collaborator Author

This test is verifying the executor works with chunking without any issues. I prefer to keep it.

@natestemen
Copy link
Member

test is verifying the executor works with chunking

Okay, but we need to define this more specifically. If we know that the LRE config (with chunking) generates $n$ circuits, then what does "works" mean? That the executor runs $n$ times? That the extrapolation gets called with $n$ datapoints? That the extrapolation function, when input $n$ expectation values, produces an expectation value?

@purva-thakre
Copy link
Collaborator Author

that the lre executor takes num_chunks without any issues. I don't think this is tested elsewhere.

@natestemen
Copy link
Member

Ah okay that's right! In that case, I think it should be sufficient to mock the executor, and ensure that it is run the correct number of times.

@purva-thakre
Copy link
Collaborator Author

I think it should be sufficient to mock the executor, and ensure that it is run the correct number of times.

Done!

@purva-thakre purva-thakre added this to the 0.43.0 milestone Jan 31, 2025
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