Exemplo n.º 1
0
def test_layered_continuous_gates_circuit(benchmark,
                                          generate_continuous_gates_circuit,
                                          nqubits, nlayers):
    circuit = generate_continuous_gates_circuit(nqubits, nlayers,
                                                [jaqcd.StateVector()])
    device = DefaultSimulator()
    benchmark(device.run, circuit, nqubits, shots=0)
Exemplo n.º 2
0
def result_str_4(task_metadata_zero_shots, additional_metadata):
    result = GateModelTaskResult(
        resultTypes=[
            ResultTypeValue(type=jaqcd.Probability(targets=[0]), value=[0.5, 0.5]),
            ResultTypeValue(
                type=jaqcd.StateVector(), value=[(0.70710678, 0), (0, 0), (0, 0), (0.70710678, 0)]
            ),
            ResultTypeValue(type=jaqcd.Expectation(observable=["y"], targets=[0]), value=0.0),
            ResultTypeValue(type=jaqcd.Variance(observable=["y"], targets=[0]), value=0.1),
            ResultTypeValue(type=jaqcd.Amplitude(states=["00"]), value={"00": (0.70710678, 0)}),
        ],
        measuredQubits=list(range(2)),
        taskMetadata=task_metadata_zero_shots,
        additionalMetadata=additional_metadata,
    )
    return result.json()
Exemplo n.º 3
0
    def _qft_operations(qubit_count):
        qft_ops = []
        for target_qubit in range(qubit_count):
            angle = np.pi / 2
            qft_ops.append(jaqcd.H(target=target_qubit))
            for control_qubit in range(target_qubit + 1, qubit_count):
                qft_ops.append(
                    jaqcd.CPhaseShift(control=control_qubit,
                                      target=target_qubit,
                                      angle=angle))
                angle /= 2

        amplitudes = [
            "".join([str(random.randint(0, 1)) for _ in range(qubit_count)])
            for _ in range(2**(qubit_count // 2))
        ]
        return jaqcd.Program(
            instructions=qft_ops,
            results=[
                jaqcd.StateVector(),
                jaqcd.Amplitude(states=amplitudes),
                jaqcd.Expectation(observable=["x"]),
            ],
        )
Exemplo n.º 4
0
def result_obj_4(task_metadata_zero_shots, additional_metadata):
    return GateModelTaskResult(
        resultTypes=[
            ResultTypeValue.construct(type=jaqcd.Probability(targets=[0]),
                                      value=np.array([0.5, 0.5])),
            ResultTypeValue.construct(
                type=jaqcd.StateVector(),
                value=np.array(
                    [complex(0.70710678, 0), 0, 0,
                     complex(0.70710678, 0)]),
            ),
            ResultTypeValue.construct(type=jaqcd.Expectation(observable=["y"],
                                                             targets=[0]),
                                      value=0.0),
            ResultTypeValue.construct(type=jaqcd.Variance(observable=["y"],
                                                          targets=[0]),
                                      value=0.1),
            ResultTypeValue.construct(type=jaqcd.Amplitude(states=["00"]),
                                      value={"00": complex(0.70710678, 0)}),
        ],
        measuredQubits=list(range(2)),
        taskMetadata=task_metadata_zero_shots,
        additionalMetadata=additional_metadata,
    )
Exemplo n.º 5
0
def test_from_braket_result_type_statevector():
    assert isinstance(from_braket_result_type(jaqcd.StateVector()), StateVector)