Skip to content

Use list for GoogleNoiseProperties.readout_errors values #7392

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

Merged

Conversation

pavoljuhas
Copy link
Collaborator

Problem: The values in SuperconductingQubitsNoiseProperties.readout_errors
and GoogleNoiseProperties.readout_errors dictionaries are declared as
np.ndarray in docstrings, but annotated aslist[float] in the code,
and can be set to either type. JSON serialization fails when assigned a list.

Solution: Always convert to list[float] following the type annotation.

This fixes serialization failure for GoogleNoiseProperties objects created
with noise_properties_from_calibration.

GoogleNoiseProperties from `calibration_to_noise_properties()`
cannot be serialized.  Here is a test for that failure.
Problem: The values in `SuperconductingQubitsNoiseProperties.readout_errors`
and `GoogleNoiseProperties.readout_errors` dictionary are declared as both
`list[float]` and `np.ndarray` and can be set with either type.  JSON
serialization fails when assigned list type.

Solution: Always convert to a `list[float]` type.

This fixes serialization failure for object constructed with
`noise_properties_from_calibration`.
@pavoljuhas pavoljuhas requested review from wcourtney, vtomole, verult and a team as code owners May 30, 2025 00:46
@github-actions github-actions bot added the size: M 50< lines changed <250 label May 30, 2025
@pavoljuhas pavoljuhas requested a review from dstrain115 May 30, 2025 00:46
@pavoljuhas
Copy link
Collaborator Author

Question @dstrain115 - The json_test_data/GoogleNoiseProperties.repr file expresses readout_errors as np.array-s:

readout_errors={
cirq.GridQubit(0, 0): np.array([0.004, 0.007], dtype=np.float64),
cirq.GridQubit(0, 1): np.array([0.005, 0.008], dtype=np.float64),
cirq.GridQubit(1, 0): np.array([0.006, 0.009], dtype=np.float64)
},

This passes tests because GoogleNoiseProperties.__eq__ uses np.allclose to compare readout_errors values.

Should we leave it as is or is it better to update GoogleNoiseProperties.repr?

Copy link

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (123cbf8) to head (e735a43).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7392      +/-   ##
==========================================
- Coverage   98.68%   98.68%   -0.01%     
==========================================
  Files        1112     1112              
  Lines       97737    97755      +18     
==========================================
+ Hits        96454    96471      +17     
- Misses       1283     1284       +1     

☔ 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.
@pavoljuhas pavoljuhas enabled auto-merge June 2, 2025 19:39
@pavoljuhas pavoljuhas added this pull request to the merge queue Jun 2, 2025
Merged via the queue into quantumlib:main with commit eebcfa0 Jun 2, 2025
35 checks passed
@pavoljuhas pavoljuhas deleted the noise-props-use-list-for-readout_errors branch June 2, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
2 participants