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

Structured Measurement Keys #4040

Closed
smitsanghavi opened this issue Apr 21, 2021 · 5 comments
Closed

Structured Measurement Keys #4040

smitsanghavi opened this issue Apr 21, 2021 · 5 comments
Assignees
Labels
area/measurements kind/design-issue A conversation around design

Comments

@smitsanghavi
Copy link
Collaborator

A class that wraps the string measurement key, encapsulating any measurement key related logic and provides various utils for users. Phased rollout to eventually move away from manipulating strings to a well defined interface.

Is your design idea/issue related to a use case or problem? Please describe.
Currently, the measurement keys are plain strings. We need more structure and logic to the key itself to have a cleaner way to:

  • Validate the keys (some characters are reserved to mean special things for e.g. ':' for nesting inside a CircuitOperation)
  • Treating measurement keys created from Qubits as special type. Remapping qubits for a MeasurementGate should also remap these keys.
  • Eliminate a lot of the brittle string parsing logic inside CircuitOperation and enable accessing different "levels" of a nested CircuitOperation more cleanly.
  • Unlock more expressive implementations for Representing Classical Data, Feed Forward and Flow Control

Describe your design idea/issue
RFC: https://tinyurl.com/structured-measurement-keys
The initial part outlines potential approaches to go about this. The "Detailed Design" goes deeper into the preferred option (based on feedback from cirq-maintainers@) and the implementation/rollout plan for it.

@smitsanghavi smitsanghavi added the kind/design-issue A conversation around design label Apr 21, 2021
CirqBot pushed a commit that referenced this issue Sep 29, 2021
It was erroneously removed in #4403 without deprecating.

Part of #4040.
@dabacon
Copy link
Collaborator

dabacon commented Mar 28, 2022

Is this done?

@daxfohl
Copy link
Contributor

daxfohl commented May 6, 2022

I think there was still a remaining task to rename and deprecate some protocols. While doing that we may want to see if we can speed up the default case for these protocols where nothing is implemented, perhaps removing some magic method options, or just creating an Operation.measurement_keys property, as the protocols do get called in tight loops during circuit construction.

@95-martin-orion
Copy link
Collaborator

@daxfohl, could you elaborate on the remaining work? IIRC, measurement_key_(objs|names) was the intended end state for the protocol renaming. I'm on board for optimizations, but those can be a separate post-1.0 issue.

@95-martin-orion 95-martin-orion self-assigned this Jun 7, 2022
@daxfohl
Copy link
Contributor

daxfohl commented Jun 7, 2022 via email

@95-martin-orion
Copy link
Collaborator

Opened #5465 to track optimizations; closing this as complete.

rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
It was erroneously removed in quantumlib#4403 without deprecating.

Part of quantumlib#4040.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/measurements kind/design-issue A conversation around design
Projects
None yet
Development

No branches or pull requests

5 participants