Skip to content

Commit

Permalink
Move moment index into circuit message (#7008)
Browse files Browse the repository at this point in the history
* Move moment index into circuit message

- This addresses design review comments that the moment_index should
be outside the Moment message to be consistent and avoid a message
construction.
- This PR also simplifies the code to deserialize all the constants
first, which removes the need for lookup tables and logic later.
- In addition, this puts the deserialization of a moment into its
own function.

* types

* typo]]]]

* Fix build protos to whatever version thing I was missing.

* Address review comments.
  • Loading branch information
dstrain115 authored Feb 4, 2025
1 parent 5c198ce commit 6c9db55
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 180 deletions.
18 changes: 11 additions & 7 deletions cirq-google/cirq_google/api/v2/program.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@ message Circuit {
// The moments of the circuit, with the first element corresponding to the
// first set of operations to apply, etc.
repeated Moment moments = 2;


// The index of the moment in the top-level constant table.
// In order to preserve ordering, either this field should be populated
// or the moments field, but not both.
// This field is used to reduce size of circuits that contain many
// repeated moments.
repeated int32 moment_indices = 3;
}

// A moment is a collection of operations and circuit operations that operate
// on a disjoint set of qubits. Conceptually, a moment represents operations
// that all occur in the same finite period of time.
message Moment {
// The index of the moment in the top-level constant table.
// If this field is populated, the other fields should be ignored
// in favor using the constant table lookup.
// This field is used to reduce size of circuits that contain many
// repeated moments.
optional int32 moment_constant_index = 3;

// All of the gate operations in the moment. Each operation and circuit
// operation must act on different qubits.
repeated Operation operations = 1;
Expand All @@ -97,6 +98,9 @@ message Moment {
// table should be preferred for circuits with repeated operations
// for improved serialization size.
repeated int32 operation_indices = 4;

// Deprecated field id, do not use.
reserved 3;
}

// The quantum circuit, specified as a series of operations at specific
Expand Down
Loading

0 comments on commit 6c9db55

Please sign in to comment.