예제 #1
0
def test_ionq() -> None:
    b = BraketBackend(
        s3_bucket=S3_BUCKET,
        s3_folder=S3_FOLDER,
        device_type="qpu",
        provider="ionq",
        device="ionQdevice",
    )
    assert b.persistent_handles
    assert b.supports_shots
    assert not b.supports_state

    # Device is fully connected
    dev = b.device()
    assert dev is not None
    arch = dev.architecture
    n = len(arch.nodes)
    assert len(arch.coupling) == n * (n - 1)

    chars = b.characterisation
    assert chars is not None
    fid = chars["fidelity"]
    assert "1Q" in fid
    assert "2Q" in fid
    assert "spam" in fid
    tim = chars["timing"]
    assert "T1" in tim
    assert "T2" in tim

    c = (
        Circuit(3)
        .add_gate(OpType.XXPhase, 0.5, [0, 1])
        .add_gate(OpType.YYPhase, 0.5, [1, 2])
        .add_gate(OpType.SWAP, [0, 2])
        .add_gate(OpType.CCX, [0, 1, 2])
    )
    assert not b.valid_circuit(c)
    b.compile_circuit(c)
    assert b.valid_circuit(c)
    h = b.process_circuit(c, 1)
    _ = b.circuit_status(h)
    b.cancel(h)

    # Circuit with unused qubits
    c = Circuit(11).H(9).CX(9, 10)
    b.compile_circuit(c)
    h = b.process_circuit(c, 1)
    b.cancel(h)
예제 #2
0
def test_rigetti() -> None:
    b = BraketBackend(
        s3_bucket=S3_BUCKET,
        s3_folder=S3_FOLDER,
        device_type="qpu",
        provider="rigetti",
        device="Aspen-9",
    )
    assert b.persistent_handles
    assert b.supports_shots
    assert not b.supports_state

    chars = b.characterisation
    assert chars is not None
    specs = chars["specs"]
    assert "1Q" in specs
    assert "2Q" in specs

    c = (
        Circuit(3)
        .add_gate(OpType.CCX, [0, 1, 2])
        .add_gate(OpType.U1, 0.5, [1])
        .add_gate(OpType.ISWAP, 0.5, [0, 2])
        .add_gate(OpType.XXPhase, 0.5, [1, 2])
    )
    assert not b.valid_circuit(c)
    b.compile_circuit(c)
    assert b.valid_circuit(c)
    h = b.process_circuit(c, 10)  # min shots = 10 for Rigetti
    _ = b.circuit_status(h)
    b.cancel(h)

    # Circuit with unused qubits
    c = Circuit(11).H(9).CX(9, 10)
    b.compile_circuit(c)
    h = b.process_circuit(c, 10)
    b.cancel(h)