Skip to content

Make the points in cirq_google v2 proto to be double#7498

Merged
BichengYing merged 11 commits intoquantumlib:mainfrom
BichengYing:u/ybc/cirq_points_double
Jul 17, 2025
Merged

Make the points in cirq_google v2 proto to be double#7498
BichengYing merged 11 commits intoquantumlib:mainfrom
BichengYing:u/ybc/cirq_points_double

Conversation

@BichengYing
Copy link
Copy Markdown
Collaborator

@BichengYing BichengYing commented Jul 15, 2025

In order to make it forward and backward compatible, i added an extra field points_fl64 and

  1. serialization phase: always write to both float points and double points_fl64
  2. deserialization phase: use points_fl64 first if it presented, if not, fall back to points.

It will temporary make the communication cost slightly higher since we communicating two points. But it will be make the transition much easier.

UPDATE: added the double field for LinSpace and Const as well.

@BichengYing BichengYing requested review from a team, verult, vtomole and wcourtney as code owners July 15, 2025 23:45
@github-actions github-actions bot added the size: S 10< lines changed <50 label Jul 15, 2025
@@ -228,6 +228,10 @@ message Points {
// The values.
repeated float points = 1;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider marking the old points with [deprecated = true] and adding a comment that the point_list should be used instead.

Copy link
Copy Markdown
Collaborator Author

@BichengYing BichengYing Jul 16, 2025

Choose a reason for hiding this comment

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

Yes, this is a good practice but we cannot add it [deprecated = true] for now (avoid unnecessary warning) because before we roll-out the latest version into the servers of all machines, this field is still used. I will add a comment first.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IIUC, deprecated fields are usable just as before except they might show deprecation warnings when used. Such warnings can be helpful to identify client code that uses the old fields.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But because of current dual writting mechanism, this warning will be popped out always while the user has no action to do when saw this warning. I feel this will confuse the external users. So I still think this [deprecated = true] should be added after all servers are updated and we stopped the dual write mechanism .


// Due to historical reason, the points are stored as float32.
// But float64 should be a better choice.
repeated double point_list = 3;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we also need to extend Linspace and ConstValue to make sure they're consistent.(http://shortn/_TLCXefjbb8)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ok, done. Note ConstValue used oneof, hence, the dual-write trick cannot work here. That one will be switched at last

@github-actions github-actions bot added size: M 50< lines changed <250 and removed size: S 10< lines changed <50 labels Jul 16, 2025
@BichengYing
Copy link
Copy Markdown
Collaborator Author

Also, fyi, to make the naming consistently, I use points_fl64, first_point_fl64 and, last_point_fl64.

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (07fb131) to head (fb99ea0).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7498   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files        1091     1091           
  Lines       96853    96884   +31     
=======================================
+ Hits        95579    95610   +31     
  Misses       1274     1274           

☔ 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.

Comment thread cirq-google/cirq_google/api/v2/run_context.proto Outdated
Copy link
Copy Markdown
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.

LGTM with some small suggestions.

Comment thread cirq-google/cirq_google/api/v2/run_context.proto Outdated
Comment thread cirq-google/cirq_google/api/v2/run_context.proto Outdated

// Due to historical reason, the points are stored as float32.
// But float64 should be a better choice.
repeated double points_fl64 = 3;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit - consider renaming to points_double here and similarly in Linspace for consistency with ConstValue.double_value.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok

Comment thread cirq-google/cirq_google/api/v2/sweeps_test.py Outdated
BichengYing and others added 5 commits July 17, 2025 10:42
Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
Copy link
Copy Markdown
Collaborator

@senecameeks senecameeks left a comment

Choose a reason for hiding this comment

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

LGTM

@BichengYing BichengYing added this pull request to the merge queue Jul 17, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants