Skip to content

Commit 57d9d21

Browse files
authored
Streamline proto serialization of circuits with duplicate moments. (#6941)
- Many circuits, in practice, have moments that are repeated in the circuit. For instance, XEB are long circuits with duplicate layers of 2 qubits gates. Long QEC experiments also have duplicate moments. - Streamline the proto serialization of these circuits so that these moments are stored only once (in the constants table). Note that this PR only adds deserialization by default and hides serialization behind a feature flag. Once this is deployed everywhere, then we can enable serialization.
1 parent e141745 commit 57d9d21

File tree

5 files changed

+242
-109
lines changed

5 files changed

+242
-109
lines changed

cirq-google/cirq_google/api/v2/program.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ message Constant {
4242

4343
// Qubits used within the circuit (only populated in v2.5+)
4444
Qubit qubit = 3;
45+
46+
// Moments used multiple times in a circuit
47+
Moment moment_value = 4;
4548
}
4649
}
4750

@@ -70,6 +73,13 @@ message Circuit {
7073
// on a disjoint set of qubits. Conceptually, a moment represents operations
7174
// that all occur in the same finite period of time.
7275
message Moment {
76+
// The index of the moment in the top-level constant table.
77+
// If this field is populated, the other fields should be ignored
78+
// in favor using the constant table lookup.
79+
// This field is used to reduce size of circuits that contain many
80+
// repeated moments.
81+
optional int32 moment_constant_index = 3;
82+
7383
// All of the gate operations in the moment. Each operation and circuit
7484
// operation must act on different qubits.
7585
repeated Operation operations = 1;

0 commit comments

Comments
 (0)