forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support serialization of GateFamilies (quantumlib#4715)
Exactly what it says: this PR uses the new type-serialization behavior to allow GateFamilies to be serialized. Additional work is still required for Gateset serialization - that behavior is not included in this PR.
- Loading branch information
1 parent
196318f
commit 39ffd16
Showing
13 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"cirq_type": "AnyIntegerPowerGateFamily", | ||
"gate": "XPowGate" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq.AnyIntegerPowerGateFamily(cirq.ops.common_gates.XPowGate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"cirq_type": "AnyUnitaryGateFamily", | ||
"num_qubits": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cirq.AnyUnitaryGateFamily(num_qubits = 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"cirq_type": "GateFamily", | ||
"gate": "XPowGate", | ||
"name": "Type GateFamily: cirq.ops.common_gates.XPowGate", | ||
"description": "Accepts `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)`", | ||
"ignore_global_phase": true | ||
}, | ||
{ | ||
"cirq_type": "GateFamily", | ||
"gate": { | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
"name": "XFamily", | ||
"description": "Just the X gate.", | ||
"ignore_global_phase": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
cirq.GateFamily(gate=cirq.ops.common_gates.XPowGate, ignore_global_phase=True), | ||
cirq.GateFamily(gate=cirq.X, name="XFamily", description="Just the X gate.", ignore_global_phase=False) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"cirq_type": "ParallelGateFamily", | ||
"gate": "XPowGate", | ||
"name": "INF Parallel Type GateFamily: cirq.ops.common_gates.XPowGate", | ||
"description": "Accepts\n1. `cirq.Gate` instances `g` s.t. `isinstance(g, cirq.ops.common_gates.XPowGate)` OR\n2. `cirq.ParallelGate` instance `g` s.t. `g.sub_gate` satisfies 1. and `cirq.num_qubits(g) <= INF` OR\n3. `cirq.Operation` instance `op` s.t. `op.gate` satisfies 1. or 2.", | ||
"max_parallel_allowed": null | ||
}, | ||
{ | ||
"cirq_type": "ParallelGateFamily", | ||
"gate": { | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
"name": "ParallelXFamily", | ||
"description": "Up to 4 parallel X gates", | ||
"max_parallel_allowed": 4 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
cirq.ParallelGateFamily(gate=cirq.ops.common_gates.XPowGate, max_parallel_allowed=None), | ||
cirq.ParallelGateFamily( | ||
gate=cirq.X, | ||
name="ParallelXFamily", | ||
description=r'''Up to 4 parallel X gates''', | ||
max_parallel_allowed=4 | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters