Skip to content

Commit 0039d36

Browse files
dstrain115mhucka
authored andcommitted
Streamline proto serialization of circuits with duplicate operations (quantumlib#6991)
* Streamline proto serialization of circuits with duplicate operations - Some circuits, such as randomized benchmarking circuits, have many repeated operations. - Streamline the proto serialization of these circuits so that these operations 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. * fix type * Addressed some of the comments. * coverage
1 parent 98314aa commit 0039d36

File tree

5 files changed

+208
-137
lines changed

5 files changed

+208
-137
lines changed

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

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

4646
// Moments used multiple times in a circuit
4747
Moment moment_value = 4;
48+
49+
// Operations used multiple times in a circuit
50+
Operation operation_value = 5;
4851
}
4952
}
5053

@@ -87,6 +90,13 @@ message Moment {
8790
// All of the circuit operations in the moment. Each operation and circuit
8891
// operation must act on different qubits.
8992
repeated CircuitOperation circuit_operations = 2;
93+
94+
// All of the operations in the moment that are stored in the constants
95+
// table. Each operation should be stored in either `operations`
96+
// or `operation_indices`. Putting operations into the symbol
97+
// table should be preferred for circuits with repeated operations
98+
// for improved serialization size.
99+
repeated int32 operation_indices = 4;
90100
}
91101

92102
// The quantum circuit, specified as a series of operations at specific

0 commit comments

Comments
 (0)