Skip to content

Commit ea033bf

Browse files
David's allows_gates_family comment
1 parent 419233b commit ea033bf

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/bloqade/cirq_utils/noise/model.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,21 @@ class GeminiNoiseModelABC(cirq.NoiseModel, MoveNoiseModelABC):
5656
"""The correlated CZ error rates as a dictionary"""
5757

5858
def __post_init__(self):
59-
is_ambiguous = (
60-
self.cz_paired_correlated_rates is not None
61-
and self.cz_paired_error_probabilities is not None
62-
)
63-
if is_ambiguous:
64-
raise ValueError(
65-
"Received both `cz_paired_correlated_rates` and `cz_paired_error_probabilities` as input. This is ambiguous, please only set one."
66-
)
67-
68-
use_default = (
59+
if (
6960
self.cz_paired_correlated_rates is None
7061
and self.cz_paired_error_probabilities is None
71-
)
72-
if use_default:
62+
):
7363
# NOTE: no input, set to default value; weird setattr for frozen dataclass
7464
object.__setattr__(
7565
self,
7666
"cz_paired_error_probabilities",
7767
_default_cz_paired_correlated_rates(),
7868
)
79-
return
69+
elif (
70+
self.cz_paired_correlated_rates is not None
71+
and self.cz_paired_error_probabilities is None
72+
):
8073

81-
if self.cz_paired_correlated_rates is not None:
8274
if self.cz_paired_correlated_rates.shape != (4, 4):
8375
raise ValueError(
8476
"Expected a 4x4 array of probabilities for cz_paired_correlated_rates"
@@ -90,23 +82,27 @@ def __post_init__(self):
9082
"cz_paired_error_probabilities",
9183
correlated_noise_array_to_dict(self.cz_paired_correlated_rates),
9284
)
93-
return
94-
95-
assert (
96-
self.cz_paired_error_probabilities is not None
97-
), "This error should not happen! Please report this issue."
85+
elif (
86+
self.cz_paired_correlated_rates is not None
87+
and self.cz_paired_error_probabilities is not None
88+
):
89+
raise ValueError(
90+
"Received both `cz_paired_correlated_rates` and `cz_paired_correlated_rates` as input. This is ambiguous, please only set one."
91+
)
9892

9993
@staticmethod
10094
def validate_moments(moments: Iterable[cirq.Moment]):
101-
allowed_target_gates: frozenset[cirq.GateFamily] = cirq.CZTargetGateset().gates
95+
reset_family = cirq.GateFamily(gate=cirq.ResetChannel, ignore_global_phase=True)
96+
allowed_target_gates: frozenset[cirq.GateFamily] = cirq.CZTargetGateset(additional_gates=[reset_family]).gates
97+
# allowed_target_gates: frozenset[cirq.GateFamily] = cirq.CZTargetGateset().gates
10298

10399
for moment in moments:
104100
for operation in moment:
105101
if not isinstance(operation, cirq.Operation):
106102
continue
107103

108104
gate = operation.gate
109-
for allowed_family in set(allowed_target_gates).union({cirq.GateFamily(gate=cirq.ops.common_channels.ResetChannel, ignore_global_phase=True)}):
105+
for allowed_family in allowed_target_gates:
110106
if gate in allowed_family:
111107
break
112108
else:

0 commit comments

Comments
 (0)