示例#1
0
def test_benchmark_2q_xeb_fidelities_parallel():
    circuits = rqcg.generate_library_of_2q_circuits(
        n_library_circuits=5,
        two_qubit_gate=cirq.ISWAP**0.5,
        max_cycle_depth=4)
    cycle_depths = [2, 3, 4]
    graph = _gridqubits_to_graph_device(cirq.GridQubit.rect(2, 2))
    combs = rqcg.get_random_combinations_for_device(
        n_library_circuits=len(circuits),
        n_combinations=2,
        device_graph=graph,
        random_state=10)

    sampled_df = sample_2q_xeb_circuits(
        sampler=cirq.Simulator(),
        circuits=circuits,
        cycle_depths=cycle_depths,
        combinations_by_layer=combs,
    )
    fid_df = benchmark_2q_xeb_fidelities(sampled_df, circuits, cycle_depths)
    n_pairs = sum(len(c.pairs) for c in combs)
    assert len(fid_df) == len(cycle_depths) * n_pairs

    fit_df = fit_exponential_decays(fid_df)
    for _, row in fit_df.iterrows():
        assert list(row['cycle_depths']) == list(cycle_depths)
        assert len(row['fidelities']) == len(cycle_depths)
示例#2
0
def test_benchmark_2q_xeb_fidelities():
    q0, q1 = cirq.LineQubit.range(2)
    circuits = [
        rqcg.random_rotations_between_two_qubit_circuit(
            q0,
            q1,
            depth=50,
            two_qubit_op_factory=lambda a, b, _: SQRT_ISWAP(a, b),
            seed=52) for _ in range(2)
    ]
    cycle_depths = np.arange(3, 50, 9)

    sampled_df = sample_2q_xeb_circuits(sampler=cirq.Simulator(seed=53),
                                        circuits=circuits,
                                        cycle_depths=cycle_depths)
    fid_df = benchmark_2q_xeb_fidelities(sampled_df, circuits, cycle_depths)
    assert len(fid_df) == len(cycle_depths)
    for _, row in fid_df.iterrows():
        assert row['cycle_depth'] in cycle_depths
        assert row['fidelity'] > 0.98

    fit_df = fit_exponential_decays(fid_df)
    for _, row in fit_df.iterrows():
        assert list(row['cycle_depths']) == list(cycle_depths)
        assert len(row['fidelities']) == len(cycle_depths)
示例#3
0
def test_benchmark_2q_xeb_fidelities(circuits_cycle_depths_sampled_df, pass_cycle_depths):
    circuits, cycle_depths, sampled_df = circuits_cycle_depths_sampled_df

    if pass_cycle_depths:
        fid_df = benchmark_2q_xeb_fidelities(sampled_df, circuits, cycle_depths)
    else:
        fid_df = benchmark_2q_xeb_fidelities(sampled_df, circuits)
    assert len(fid_df) == len(cycle_depths)
    assert sorted(fid_df['cycle_depth'].unique()) == cycle_depths.tolist()
    assert np.all(fid_df['fidelity'] > 0.98)

    fit_df = fit_exponential_decays(fid_df)
    for _, row in fit_df.iterrows():
        assert list(row['cycle_depths']) == list(cycle_depths)
        assert len(row['fidelities']) == len(cycle_depths)