def test_make_floquet_request_for_moments_merges_compatible_sets() -> None: a, b, c, d, e, f = cirq.LineQubit.range(6) circuit = cirq.Circuit([cirq.X(a), cirq.Y(c)]) circuit += cirq.Moment([SQRT_ISWAP_GATE.on(a, b)]) circuit += cirq.Moment( [SQRT_ISWAP_GATE.on(b, c), SQRT_ISWAP_GATE.on(d, e)]) circuit += cirq.Moment([SQRT_ISWAP_GATE.on(c, d)]) circuit += cirq.Moment( [SQRT_ISWAP_GATE.on(a, f), SQRT_ISWAP_GATE.on(d, e)]) options = WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION circuit_with_calibration, requests = workflow.prepare_floquet_characterization_for_moments( circuit, options=options) assert requests == [ cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), (c, d)), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, f), (b, c), (d, e)), gate=SQRT_ISWAP_GATE, options=options), ] assert circuit_with_calibration.circuit == circuit assert circuit_with_calibration.moment_to_calibration == [None, 0, 1, 0, 1]
def test_make_floquet_request_for_moments_does_not_merge_sub_sets_when_disabled( ) -> None: a, b, c, d, e = cirq.LineQubit.range(5) circuit = cirq.Circuit([ [cirq.X(a), cirq.Y(c)], [SQRT_ISWAP_GATE.on(a, b), SQRT_ISWAP_GATE.on(c, d)], [SQRT_ISWAP_GATE.on(b, c)], [SQRT_ISWAP_GATE.on(a, b)], ]) circuit += cirq.Circuit( [SQRT_ISWAP_GATE.on(b, c), SQRT_ISWAP_GATE.on(d, e)], [SQRT_ISWAP_GATE.on(b, c)], ) options = WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION circuit_with_calibration, requests = workflow.prepare_floquet_characterization_for_moments( circuit, options=options, merge_subsets=False) assert requests == [ cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), (c, d)), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((b, c), ), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), ), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((b, c), (d, e)), gate=SQRT_ISWAP_GATE, options=options), ] assert circuit_with_calibration.circuit == circuit assert circuit_with_calibration.moment_to_calibration == [ None, 0, 1, 2, 3, 1 ]
def test_make_floquet_request_for_moments_merges_many_circuits() -> None: options = WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION a, b, c, d, e = cirq.LineQubit.range(5) circuit_1 = cirq.Circuit([ [cirq.X(a), cirq.Y(c)], [SQRT_ISWAP_GATE.on(a, b), SQRT_ISWAP_GATE.on(c, d)], [SQRT_ISWAP_GATE.on(b, c)], [SQRT_ISWAP_GATE.on(a, b)], ]) circuit_with_calibration_1, requests_1 = workflow.prepare_floquet_characterization_for_moments( circuit_1, options=options) assert requests_1 == [ cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), (c, d)), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((b, c), ), gate=SQRT_ISWAP_GATE, options=options), ] assert circuit_with_calibration_1.circuit == circuit_1 assert circuit_with_calibration_1.moment_to_calibration == [None, 0, 1, 0] circuit_2 = cirq.Circuit( [SQRT_ISWAP_GATE.on(b, c), SQRT_ISWAP_GATE.on(d, e)]) circuit_with_calibration_2, requests_2 = workflow.prepare_floquet_characterization_for_moments( circuit_2, options=options, initial=requests_1) assert requests_2 == [ cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), (c, d)), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((b, c), (d, e)), gate=SQRT_ISWAP_GATE, options=options), ] assert circuit_with_calibration_2.circuit == circuit_2 assert circuit_with_calibration_2.moment_to_calibration == [1]
def test_make_floquet_request_for_moments() -> None: a, b, c, d = cirq.LineQubit.range(4) circuit = cirq.Circuit([ [cirq.X(a), cirq.Y(c)], [SQRT_ISWAP_GATE.on(a, b), SQRT_ISWAP_GATE.on(c, d)], [SQRT_ISWAP_GATE.on(b, c)], [cirq.WaitGate(duration=cirq.Duration(micros=5.0)).on(b)], ]) options = WITHOUT_CHI_FLOQUET_PHASED_FSIM_CHARACTERIZATION circuit_with_calibration, requests = workflow.prepare_floquet_characterization_for_moments( circuit, options=options) assert requests == [ cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((a, b), (c, d)), gate=SQRT_ISWAP_GATE, options=options), cirq_google.calibration.FloquetPhasedFSimCalibrationRequest( pairs=((b, c), ), gate=SQRT_ISWAP_GATE, options=options), ] assert circuit_with_calibration.circuit == circuit assert circuit_with_calibration.moment_to_calibration == [None, 0, 1, None]