Skip to content

Commit

Permalink
Streamline proto serialization of circuits with duplicate operations (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
dstrain115 authored Jan 30, 2025
1 parent 6ebc78b commit 08b1efb
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 137 deletions.
10 changes: 10 additions & 0 deletions cirq-google/cirq_google/api/v2/program.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ message Constant {

// Moments used multiple times in a circuit
Moment moment_value = 4;

// Operations used multiple times in a circuit
Operation operation_value = 5;
}
}

Expand Down Expand Up @@ -87,6 +90,13 @@ message Moment {
// All of the circuit operations in the moment. Each operation and circuit
// operation must act on different qubits.
repeated CircuitOperation circuit_operations = 2;

// All of the operations in the moment that are stored in the constants
// table. Each operation should be stored in either `operations`
// or `operation_indices`. Putting operations into the symbol
// table should be preferred for circuits with repeated operations
// for improved serialization size.
repeated int32 operation_indices = 4;
}

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

0 comments on commit 08b1efb

Please sign in to comment.