Skip to content

Commit 1c55f3f

Browse files
Partial Support for tags in cirq_google protos (#7044)
* Partial Support for tags in cirq_google protos - This adds several tags to cirq_google protos, and also adds partial support for serialization and deserialization of tags. Note: still pending are arguments for InternalTag objects and better ability to serialize/deserialize internal tags that are not public. * Update cirq-google/cirq_google/ops/fsim_via_model_tag.py Co-authored-by: Pavol Juhas <[email protected]> * Update cirq-google/cirq_google/ops/physical_z_tag.py Co-authored-by: Pavol Juhas <[email protected]> * Update cirq-google/cirq_google/ops/internal_tag.py Co-authored-by: Pavol Juhas <[email protected]> * Update cirq-google/cirq_google/serialization/circuit_serializer.py Co-authored-by: Pavol Juhas <[email protected]> * Address some comments. * Address other comment. * Solve all the CI problems. --------- Co-authored-by: Pavol Juhas <[email protected]>
1 parent 83f3579 commit 1c55f3f

13 files changed

+675
-137
lines changed

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

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ message Constant {
4848

4949
// Operations used multiple times in a circuit
5050
Operation operation_value = 5;
51+
52+
// Tags used multiple times in a circuit
53+
Tag tag_value = 6;
5154
}
5255
}
5356

@@ -268,19 +271,110 @@ message Operation {
268271
int32 token_constant_index = 5;
269272
}
270273

274+
// To be deprecated
271275
repeated Tag tags = 22;
276+
277+
// Indices in the constant table for tags associated with the operation
278+
repeated int32 tag_indices = 23;
272279
}
273280

274281
message DynamicalDecouplingTag {
275282
optional string protocol = 1;
276283
}
277284

285+
286+
// Messages for tags that can modify operations
287+
// These are often directives to hardware specifying
288+
// how the operation should be executed.
278289
message Tag {
279290
oneof tag {
291+
// Tag to denote a composite dynamical decoupling operation.
292+
// Should generally be applied to cirq.I gates.
280293
DynamicalDecouplingTag dynamical_decoupling = 1;
294+
295+
// Directs the hardware to ignore moment-based
296+
// synchronization and to instead schedule
297+
// operations as soon as possible for these qubits.
298+
NoSyncTag no_sync = 2;
299+
300+
// Operation should do phase matching to match phase
301+
// required for subsequent operations
302+
PhaseMatchTag phase_match = 3;
303+
304+
// Only applicable to Z gates and other gates
305+
// that have Z gates as part of their internal operation
306+
// This indicates that the Z gates could be executed on
307+
// hardware rather than be computed virtually as part
308+
// of phase matching.
309+
PhysicalZTag physical_z = 4;
310+
311+
// Indicates that the operations are classical states
312+
ClassicalStateTag classical_state = 5;
313+
314+
// Field id 6 Reserved for OverlayTag, will add in a subsequent PR.
315+
316+
// Uses parameter model to interpolate FSim gate.
317+
FSimViaModelTag fsim_via_model = 7;
318+
319+
// Catch-all for all gates that do not fit into the
320+
// above tags.
321+
InternalTag internal_tag = 8;
281322
}
282323
}
283324

325+
326+
// Tag for operations that should do phase matching to match phase
327+
// required for subsequent operations
328+
message PhaseMatchTag {
329+
}
330+
331+
message PhysicalZTag {
332+
}
333+
334+
// Tag to indicate that a state prep circuit produces a classical state.
335+
// This serves as a hint to the compiler that we can ignore virtual Z phases
336+
message ClassicalStateTag {
337+
}
338+
339+
340+
message FSimViaModelTag {
341+
}
342+
343+
// Tag to remove moment-based synchronization
344+
// The reverse and forward arguments control the
345+
// number of moments to reverse synchronization.
346+
message NoSyncTag {
347+
oneof rev {
348+
// Number of synchronizations before the operation to remove
349+
int32 reverse = 1;
350+
351+
// Remove all possible synchronizations
352+
bool remove_all_syncs_before = 2;
353+
}
354+
oneof fwd {
355+
// Number of synchronizations after the operation to remove
356+
int32 forward = 3;
357+
358+
// Remove all possible synchronizations
359+
bool remove_all_syncs_after = 4;
360+
}
361+
}
362+
363+
364+
// Tag to represent any internal tags or tags not yet
365+
// implemented in the proto.
366+
message InternalTag {
367+
// Name of the tag
368+
string tag_name = 1;
369+
// Python package of the Tag
370+
string tag_package = 2;
371+
372+
// Instantiation arguments of the Tag
373+
map<string, Arg> tag_args = 3;
374+
map<string, CustomArg> custom_args = 4;
375+
}
376+
377+
284378
// The instruction identifying the action taken on the quantum computer.
285379
message Gate {
286380
// Name for the Gate.

cirq-google/cirq_google/api/v2/program_pb2.py

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

0 commit comments

Comments
 (0)