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

Add support for const sweep with None #6729

Merged
merged 9 commits into from
Sep 17, 2024

Conversation

BichengYing
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.83%. Comparing base (2adc218) to head (da9f4dc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6729   +/-   ##
=======================================
  Coverage   97.83%   97.83%           
=======================================
  Files        1077     1077           
  Lines       92485    92524   +39     
=======================================
+ Hits        90484    90523   +39     
  Misses       2001     2001           

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

@BichengYing BichengYing marked this pull request as ready for review September 16, 2024 05:07
cirq-google/cirq_google/api/v2/run_context.proto Outdated Show resolved Hide resolved
cirq-google/cirq_google/api/v2/sweeps_test.py Outdated Show resolved Hide resolved
@@ -63,7 +91,10 @@ def sweep_to_proto(
out.single_sweep.parameter.units = sweep.metadata.units
elif isinstance(sweep, cirq.Points) and not isinstance(sweep.key, sympy.Expr):
out.single_sweep.parameter_key = sweep.key
out.single_sweep.points.points.extend(sweep.points)
if len(sweep.points) == 1 and sweep.points[0] is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this support arbitrary const values, not just None? If so, can you add a test for the new logic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, it can. But I found other places used sweep with single point as well. So I add this extra condition to avoid the change of previous behavior. (Add the comment in the code base). I think we can remove this is None later when it becomes necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

How many places in cirq use const sweep points? If they're only tests, can we change them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not many. All of them should be under the test of cirq-google only. I have modified them all.(One improvement is we can distinguish float and int now) PTAL.

But I am not sure if Cirq Server in Pyle will be impacted or not. If always using sweep_to_proto and sweep_from_proto in pair, we don't need to worry. Otherwise, we should revert it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In cirq_server we always use sweep_from_proto to decode from sweep_to_proto so this should be fine.

Copy link
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.

Great improvement!

@senecameeks
Copy link
Collaborator

@BichengYing please add a test for supporting arbitrary values

@BichengYing
Copy link
Collaborator Author

BichengYing commented Sep 17, 2024

please add a test for supporting arbitrary values

Done. Added more tests

@BichengYing BichengYing merged commit d74e0dc into quantumlib:main Sep 17, 2024
34 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.

2 participants