12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- """Creates the abstraction for multi moment gauge compiling as a cirq transformer."""
16
-
17
- from __future__ import annotations
15
+ """Defines the abstraction for multi-moment gauge compiling as a cirq transformer."""
18
16
19
17
import abc
20
18
19
+ from attrs import field , frozen
21
20
import numpy as np
22
21
23
22
from cirq import circuits , ops
@@ -45,7 +44,6 @@ def __init__(
45
44
self ,
46
45
target : ops .Gate | ops .Gateset | ops .GateFamily ,
47
46
supported_gates : ops .Gateset = ops .Gateset (),
48
- rng : np .random .Generator = np .random .default_rng (),
49
47
) -> None :
50
48
"""Constructs a MultiMomentGaugeTransformer.
51
49
@@ -56,15 +54,13 @@ def __init__(
56
54
supported_gates: Determines what other gates, in addition to the target gates,
57
55
are permitted within the gauge moments. If a moment contains a gate not found
58
56
in either target or supported_gates, it won't be gauged.
59
- rng: A pseudorandom number generator.
60
57
"""
61
58
self .target = ops .GateFamily (target ) if isinstance (target , ops .Gate ) else target
62
59
self .supported_gates = (
63
60
ops .GateFamily (supported_gates )
64
61
if isinstance (supported_gates , ops .Gate )
65
62
else supported_gates
66
63
)
67
- self .rng = rng
68
64
69
65
@abc .abstractmethod
70
66
def gauge_on_moments (self , moments_to_gauge : list [circuits .Moment ]) -> list [circuits .Moment ]:
@@ -78,11 +74,14 @@ def gauge_on_moments(self, moments_to_gauge: list[circuits.Moment]) -> list[circ
78
74
"""
79
75
80
76
@abc .abstractmethod
81
- def sample_left_moment (self , active_qubits : frozenset [ops .Qid ]) -> circuits .Moment :
77
+ def sample_left_moment (
78
+ self , active_qubits : frozenset [ops .Qid ], rng : np .random .Generator
79
+ ) -> circuits .Moment :
82
80
"""Samples a random single-qubit moment to be inserted before the target block.
83
81
84
82
Args:
85
83
active_qubits: The qubits on which the sampled gates should be applied.
84
+ rng: A pseudorandom number generator.
86
85
87
86
Returns:
88
87
The sampled moment.
0 commit comments