Exemple #1
0
def test_qpu_run():
    config = PyquilConfig()
    if config.qpu_url and config.qpu_compiler_url:
        g = nx.Graph()
        g.add_node(0)
        device = NxDevice(g)

        qc = QuantumComputer(
            name="pyQuil test QC",
            qam=QPU(endpoint=config.qpu_url, user="******"),
            device=device,
            compiler=QPUCompiler(
                quilc_endpoint=config.quilc_url,
                qpu_compiler_endpoint=config.qpu_compiler_url,
                device=device,
            ),
        )
        bitstrings = qc.run_and_measure(program=Program(X(0)), trials=1000)
        assert bitstrings[0].shape == (1000, )
        assert np.mean(bitstrings[0]) > 0.8
        bitstrings = qc.run(qc.compile(Program(X(0))))
        assert bitstrings.shape == (0, 0)
    else:
        pytest.skip(
            "QPU or compiler-server not available; skipping QPU run test.")
Exemple #2
0
def qpu_compiler(test_device):
    try:
        config = PyquilConfig()
        compiler = QPUCompiler(endpoint=config.compiler_url, device=test_device, timeout=0.5)
        compiler.quil_to_native_quil(Program(I(0)))
        return compiler
    except Exception as e:
        return pytest.skip(f"This test requires compiler connection: {e}")
Exemple #3
0
def mock_qpu_compiler(request, m_endpoints, compiler: QVMCompiler):
    return QPUCompiler(
        quilc_endpoint=compiler.client.endpoint,
        qpu_compiler_endpoint=m_endpoints[0],
        device=NxDevice(nx.Graph([(0, 1)])),
    )
Exemple #4
0
def mock_compiler(request, m_endpoints):
    return QPUCompiler(endpoint=m_endpoints[0],
                       device=NxDevice(nx.Graph([(0, 1)])))