Skip to content

Commit b1dc973

Browse files
authored
Proto serialization v25 (#4333)
This PR creates a new class called CircuitSerializer that can serialize Circuits into protocol buffers more efficiently than existing mechanisms. This class is similar to SerializableGateSet and op_(de)serializer, in that it serializes and deserializes cirq.Circuits into Program protocol buffers, but it is about 60% more space efficient and has significant time savings as well. This serializer works by changing the Gate field and Args dict to a specific message for each allowed gate type. It changes Qubits from a repeated Qubit message, to an index in the constant message. This PR also adds a FloatArg message which is specific to Arguments where it is known the value will be a float (or a sympy expression).
1 parent fb91578 commit b1dc973

19 files changed

+3050
-418
lines changed

cirq-google/cirq_google/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
optimized_for_xmon,
112112
)
113113

114+
from cirq_google.circuit_serializer import (
115+
CircuitSerializer,
116+
)
117+
114118
from cirq_google.op_deserializer import (
115119
CircuitOpDeserializer,
116120
DeserializingArg,

cirq-google/cirq_google/api/v1/operations_pb2.py

Lines changed: 39 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)