Skip to content

Conversation

dstrain115
Copy link
Collaborator

  • Tags were added to Moments this month.
  • Adds the ability to serialize tags on Moments using cirq_google protos.

- Tags were added to Moments this month.
- Adds the ability to serialize tags on Moments using
cirq_google protos.
@dstrain115 dstrain115 requested review from wcourtney, vtomole, verult and a team as code owners July 15, 2025 17:45
@github-actions github-actions bot added the size: L 250< lines changed <1000 label Jul 15, 2025
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.68%. Comparing base (fee1d37) to head (0067c6d).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7493   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files        1091     1091           
  Lines       96853    96865   +12     
=======================================
+ Hits        95575    95590   +15     
+ Misses       1278     1275    -3     

☔ 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 self-assigned this Jul 15, 2025
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.

The DiscountTag does not make it through the serde loop. Otherwise LGTM.

@@ -168,6 +168,11 @@ def _serialize_circuit(
raw_constants[op] = op_index
moment_proto.operation_indices.append(op_index)

for tag in moment.tags:
self._serialize_tag(
tag, moment_proto, constants=constants, raw_constants=raw_constants
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit - please update type annotation for the msg argument of _serialize_tag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

cirq.Moment(cirq.Z(cirq.GridQubit(2, 2))).with_tags(cg.CalibrationTag("abc")),
)
deserialized_circuit = serializer.deserialize(serializer.serialize(original_circuit))
assert original_circuit == deserialized_circuit
Copy link
Collaborator

@pavoljuhas pavoljuhas Jul 15, 2025

Choose a reason for hiding this comment

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

Somehow the DiscountTag does not appear in deserialized_circuit[0].tags. Please add an explicit checks for the expected moment tags. Moment.__eq__ seems to compare only the operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, that's a very good call! Nice reviewing!
I added the checks. I forgot that the DiscountTag needs a custom serializer. Fixed.

@dstrain115 dstrain115 requested a review from pavoljuhas July 16, 2025 14:03
@dstrain115 dstrain115 added this pull request to the merge queue Jul 17, 2025
Merged via the queue into quantumlib:main with commit 731f1bf Jul 17, 2025
35 checks passed
@dstrain115 dstrain115 deleted the add_moment_tags_proto branch July 17, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants