Skip to content

Commit c712e04

Browse files
eliottrosenbergrht
authored andcommitted
Remove checks so that hold_time is sweepable (quantumlib#5919)
Allows the hold time in `CouplerPulse` to be swept. See quantumlib#5918
1 parent 031365b commit c712e04

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

cirq-google/cirq_google/experimental/ops/coupler_pulse.py

-20
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
import cirq
2020

2121

22-
_MIN_DURATION = cirq.Duration(nanos=0)
23-
_MAX_DURATION = cirq.Duration(nanos=200)
24-
25-
2622
@cirq.value_equality(approximate=True)
2723
class CouplerPulse(cirq.ops.Gate):
2824
r"""Tunable pulse for entangling adjacent qubits.
@@ -67,28 +63,12 @@ def __init__(
6763
rise_time: Width of the rising (or falling) action of the trapezoidal pulse.
6864
padding_time: Symmetric padding around the coupler pulse.
6965
70-
Raises:
71-
ValueError: If any time is negative or if the total pulse is too long.
7266
"""
73-
if hold_time < _MIN_DURATION:
74-
raise ValueError(f'hold_time must be greater than {_MIN_DURATION}')
75-
if padding_time < _MIN_DURATION:
76-
raise ValueError(f'padding_time must be greater than {_MIN_DURATION}')
77-
if rise_time < _MIN_DURATION:
78-
raise ValueError(f'rise_time must be greater than {_MIN_DURATION}')
79-
8067
self.hold_time = hold_time
8168
self.coupling_mhz = coupling_mhz
8269
self.rise_time = rise_time or cirq.Duration(nanos=8)
8370
self.padding_time = padding_time or cirq.Duration(nanos=2.5)
8471

85-
total_time = hold_time + 2 * self.rise_time + 2 * self.padding_time
86-
if total_time > _MAX_DURATION:
87-
raise ValueError(
88-
f'Total time of coupler pulse ({total_time}) '
89-
f'cannot be greater than {_MAX_DURATION}'
90-
)
91-
9272
def num_qubits(self) -> int:
9373
return 2
9474

cirq-google/cirq_google/experimental/ops/coupler_pulse_test.py

-34
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import pytest
1514

1615
import cirq
1716
import cirq_google.experimental.ops.coupler_pulse as coupler_pulse
@@ -80,39 +79,6 @@ def test_equality():
8079
)
8180

8281

83-
def test_coupler_pulse_validation():
84-
with pytest.raises(ValueError, match='Total time of coupler pulse'):
85-
_ = coupler_pulse.CouplerPulse(
86-
hold_time=cirq.Duration(nanos=210), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=10)
87-
)
88-
with pytest.raises(ValueError, match='hold_time must be greater'):
89-
_ = coupler_pulse.CouplerPulse(
90-
hold_time=cirq.Duration(nanos=-10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=20)
91-
)
92-
with pytest.raises(ValueError, match='Total time of coupler pulse'):
93-
_ = coupler_pulse.CouplerPulse(
94-
hold_time=cirq.Duration(nanos=10),
95-
coupling_mhz=25.0,
96-
rise_time=cirq.Duration(nanos=20),
97-
padding_time=cirq.Duration(nanos=200),
98-
)
99-
with pytest.raises(ValueError, match='padding_time must be greater'):
100-
_ = coupler_pulse.CouplerPulse(
101-
hold_time=cirq.Duration(nanos=10),
102-
coupling_mhz=25.0,
103-
rise_time=cirq.Duration(nanos=20),
104-
padding_time=cirq.Duration(nanos=-20),
105-
)
106-
with pytest.raises(ValueError, match='rise_time must be greater'):
107-
_ = coupler_pulse.CouplerPulse(
108-
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=-1)
109-
)
110-
with pytest.raises(ValueError, match='Total time of coupler pulse'):
111-
_ = coupler_pulse.CouplerPulse(
112-
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=302)
113-
)
114-
115-
11682
def test_coupler_pulse_str_repr():
11783
gate = coupler_pulse.CouplerPulse(
11884
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=18)

0 commit comments

Comments
 (0)