Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove checks so that hold_time is sweepable #5919

Merged
merged 4 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions cirq-google/cirq_google/experimental/ops/coupler_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
import cirq


_MIN_DURATION = cirq.Duration(nanos=0)
_MAX_DURATION = cirq.Duration(nanos=200)


@cirq.value_equality(approximate=True)
class CouplerPulse(cirq.ops.Gate):
r"""Tunable pulse for entangling adjacent qubits.
Expand Down Expand Up @@ -67,28 +63,12 @@ def __init__(
rise_time: Width of the rising (or falling) action of the trapezoidal pulse.
padding_time: Symmetric padding around the coupler pulse.

Raises:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: also remove preceding blank line

ValueError: If any time is negative or if the total pulse is too long.
"""
if hold_time < _MIN_DURATION:
raise ValueError(f'hold_time must be greater than {_MIN_DURATION}')
if padding_time < _MIN_DURATION:
raise ValueError(f'padding_time must be greater than {_MIN_DURATION}')
if rise_time < _MIN_DURATION:
raise ValueError(f'rise_time must be greater than {_MIN_DURATION}')

self.hold_time = hold_time
self.coupling_mhz = coupling_mhz
self.rise_time = rise_time or cirq.Duration(nanos=8)
self.padding_time = padding_time or cirq.Duration(nanos=2.5)

total_time = hold_time + 2 * self.rise_time + 2 * self.padding_time
if total_time > _MAX_DURATION:
raise ValueError(
f'Total time of coupler pulse ({total_time}) '
f'cannot be greater than {_MAX_DURATION}'
)

def num_qubits(self) -> int:
return 2

Expand Down
34 changes: 0 additions & 34 deletions cirq-google/cirq_google/experimental/ops/coupler_pulse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest

import cirq
import cirq_google.experimental.ops.coupler_pulse as coupler_pulse
Expand Down Expand Up @@ -80,39 +79,6 @@ def test_equality():
)


def test_coupler_pulse_validation():
with pytest.raises(ValueError, match='Total time of coupler pulse'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=210), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=10)
)
with pytest.raises(ValueError, match='hold_time must be greater'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=-10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=20)
)
with pytest.raises(ValueError, match='Total time of coupler pulse'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=10),
coupling_mhz=25.0,
rise_time=cirq.Duration(nanos=20),
padding_time=cirq.Duration(nanos=200),
)
with pytest.raises(ValueError, match='padding_time must be greater'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=10),
coupling_mhz=25.0,
rise_time=cirq.Duration(nanos=20),
padding_time=cirq.Duration(nanos=-20),
)
with pytest.raises(ValueError, match='rise_time must be greater'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=-1)
)
with pytest.raises(ValueError, match='Total time of coupler pulse'):
_ = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=302)
)


def test_coupler_pulse_str_repr():
gate = coupler_pulse.CouplerPulse(
hold_time=cirq.Duration(nanos=10), coupling_mhz=25.0, rise_time=cirq.Duration(nanos=18)
Expand Down