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

CircuitOperation proto #3891

Merged
merged 10 commits into from
Mar 17, 2021
Merged

Conversation

95-martin-orion
Copy link
Collaborator

Proposed changes to the v2 API to support CircuitOperations.

I've made an effort to keep this extensible, particularly regarding measurement keys and repetitions as both are expected to change in the future. Please let me know if you see any potential pain points for future changes in this space.

@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Mar 9, 2021
@95-martin-orion
Copy link
Collaborator Author

Initial prototypes for (de-)serializers using this format are promising as far as backwards-compatibility is concerned. I haven't been able to fully test them yet, but I'd like to get this solidified before committing too much time towards it.

@95-martin-orion
Copy link
Collaborator Author

This PR is part of #3634.

@95-martin-orion
Copy link
Collaborator Author

See this follow-up PR on my fork for how this looks when used in serialization.

cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
// Indicates that qubit "source" should be replaced with "target".
message QubitPair {
Qubit source = 1;
Qubit target = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to nitpick, but I still feel like "source" and "target" is ambiguous. Is this saying that the qubit id appearing in the outer circuit is the source and should be replaced by the target value in the inner circuit, or the other way around? I'd really prefer to use something like "inner" and "outer" because the containment relationship is unambiguous (one circuit contains the other as an operation, not the other way around).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed offline: inner and outer only make sense in the context of CircuitOperation, where we have comments documenting the behavior of these maps.

Switched these to key/value to more closely align with the non-proto CircuitOperation object.

Copy link
Contributor

@maffoo maffoo left a comment

Choose a reason for hiding this comment

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

Minor command about docs, then LGTM.

cirq/google/api/v2/program.proto Outdated Show resolved Hide resolved
@95-martin-orion
Copy link
Collaborator Author

Holding out for approval from @dstrain115 prior to merging.

// of repetitions or a list of repetition IDs.
RepetitionSpecification repetition_specification = 2;

// Map from qubits in the "inner" circuit (referenced by
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure I understand why it is called inner and outer circuit, but which one is which is clarified in the comment, so I guess it is fine.

@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 17, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 17, 2021
@CirqBot
Copy link
Collaborator

CirqBot commented Mar 17, 2021

Automerge cancelled: A required status check is not present.

Missing statuses: ['Build docs', 'Build protos', 'Changed Notebooks Isolated Test against Cirq stable', 'Changed files test', 'Coverage check', 'Doc test', 'Format check', 'Lint check', 'Misc check', 'Notebook formatting', 'Pytest MacOS (3.7)', 'Pytest MacOS (3.8)', 'Pytest Ubuntu (3.7)', 'Pytest Ubuntu (3.8)', 'Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Type check', 'cla/google']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 17, 2021
@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 17, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 17, 2021
@CirqBot
Copy link
Collaborator

CirqBot commented Mar 17, 2021

Automerge cancelled: A required status check is not present.

Missing statuses: ['cla/google']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 17, 2021
@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 17, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 17, 2021
@CirqBot CirqBot merged commit 229b204 into quantumlib:master Mar 17, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Mar 17, 2021
CirqBot pushed a commit that referenced this pull request May 24, 2021
Follow up for #3891. Part of #3634.

This PR adds the `CircuitOp(De)serializer` classes and updates existing behavior to handle them appropriately, including:
- Addition of `Op(De)serializer` superclasses for operation (de-)serializers
- Backwards-compatible conversion of `GateOp(De)serializer` fields to non-public, with public properties
- Updates and deprecations for names made awkward by this change (e.g. `gate_type` -> `internal_type`)

Changes **not** included in this PR:
- Add `CircuitOperation` (de-)serializers to the default QCS gateset
NoureldinYosri pushed a commit to NoureldinYosri/Cirq that referenced this pull request May 25, 2021
Follow up for quantumlib#3891. Part of quantumlib#3634.

This PR adds the `CircuitOp(De)serializer` classes and updates existing behavior to handle them appropriately, including:
- Addition of `Op(De)serializer` superclasses for operation (de-)serializers
- Backwards-compatible conversion of `GateOp(De)serializer` fields to non-public, with public properties
- Updates and deprecations for names made awkward by this change (e.g. `gate_type` -> `internal_type`)

Changes **not** included in this PR:
- Add `CircuitOperation` (de-)serializers to the default QCS gateset
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Follow up for quantumlib#3891. Part of quantumlib#3634.

This PR adds the `CircuitOp(De)serializer` classes and updates existing behavior to handle them appropriately, including:
- Addition of `Op(De)serializer` superclasses for operation (de-)serializers
- Backwards-compatible conversion of `GateOp(De)serializer` fields to non-public, with public properties
- Updates and deprecations for names made awkward by this change (e.g. `gate_type` -> `internal_type`)

Changes **not** included in this PR:
- Add `CircuitOperation` (de-)serializers to the default QCS gateset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants