Skip to content

Conversation

ddddddanni
Copy link
Contributor

@ddddddanni ddddddanni commented Sep 1, 2025

This PR updates the tolerance of the np.isclose assertion used to validate the mitigated expectation value against its ideal value. The tolerance is being increased from 4 * mitigated_stddev to 10 * mitigated_stddev.
The nature of calculating a Pauli expectation is to statistically estimate the value by sampling from measurement outcomes a finite number of times, which by chance can lead to a small probability of the result deviate from the ideal value by > 4 * standard deviations. Increasing the tolerance to 10 * mitigated_stddev can makes the test much more robust against these statistical fluctuations.

Fixes #7612

@github-actions github-actions bot added the size: S 10< lines changed <50 label Sep 1, 2025
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.40%. Comparing base (d0e2bc5) to head (dd51998).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7627      +/-   ##
==========================================
- Coverage   97.50%   97.40%   -0.11%     
==========================================
  Files        1103     1103              
  Lines       99707    99915     +208     
==========================================
+ Hits        97222    97324     +102     
- Misses       2485     2591     +106     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

It feels a bit of an overkill to both increase the tolerance
and retry tests. I tried to run this test module repeatedly
~500 times without the retry decorator and it did not fail
once (the main branch would fail about 6 times).

Can you please remove the retry decorator?

@ddddddanni
Copy link
Contributor Author

It feels a bit of an overkill to both increase the tolerance and retry tests. I tried to run this test module repeatedly ~500 times without the retry decorator and it did not fail once (the main branch would fail about 6 times).

Can you please remove the retry decorator?

Done ; )

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

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

Thank you!

@pavoljuhas pavoljuhas enabled auto-merge September 5, 2025 00:57
@pavoljuhas pavoljuhas added this pull request to the merge queue Sep 5, 2025
Merged via the queue into quantumlib:main with commit c334f75 Sep 5, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky unit test test_group_pauli_string_measurement_errors_no_noise_with_coefficient
2 participants