Пример #1
0
def test_rigetti_qcs_aspen_device_valid_operation(
        operation: cirq.Operation, qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice throws no error when validating 2Q operations on
    adjacent qubits
    """
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    device.validate_operation(operation)
Пример #2
0
def test_rigetti_qcs_aspen_device_invalid_operation(
        operation: cirq.Operation, qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice throws error when validating 2Q operations on
    non-adjacent qubits
    """
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    with pytest.raises(UnsupportedRigettiQCSOperation):
        device.validate_operation(operation)
Пример #3
0
def test_rigetti_qcs_aspen_device_qubits(qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice returns accurate set of qubits"""
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    expected_qubits = set()
    for i in range(4):
        for j in range(8):
            expected_qubits.add(AspenQubit(octagon=i, octagon_position=j))
    assert expected_qubits == set(device.qubits())
Пример #4
0
def test_rigetti_qcs_aspen_device_non_existent_qubit(
        qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice throws error when qubit does not exist on device"""
    # test device may only be initialized with Aspen ISA.
    device_with_limited_nodes = RigettiQCSAspenDevice(
        isa=InstructionSetArchitecture.from_dict(qcs_aspen8_isa.to_dict()))
    device_with_limited_nodes.isa.architecture.nodes = [Node(node_id=10)]
    with pytest.raises(UnsupportedQubit):
        device_with_limited_nodes.validate_qubit(cirq.GridQubit(0, 0))
Пример #5
0
def test_rigetti_qcs_aspen_device_topology(
        qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice topological nodes and edges"""
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)

    assert len(device.qubit_topology.nodes) == 32
    assert len(device.qubit_topology.edges) == 38
Пример #6
0
def test_rigetti_qcs_aspen_device_family_validation(
        qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice validates architecture family on initialization"""
    non_aspen_isa = InstructionSetArchitecture.from_dict(
        qcs_aspen8_isa.to_dict())
    non_aspen_isa.architecture.family = "not-aspen"  # type: ignore
    with pytest.raises(UnsupportedRigettiQCSQuantumProcessor):
        RigettiQCSAspenDevice(isa=non_aspen_isa)
Пример #7
0
def test_rigetti_qcs_aspen_device_valid_qubit(
    qubit: cirq.Qid, qcs_aspen8_isa: InstructionSetArchitecture
):
    """test RigettiQCSAspenDevice throws no error on valid qubits or operations on those qubits"""
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    device.validate_qubit(qubit)
    device.validate_operation(cirq.I(qubit))
Пример #8
0
def test_rigetti_qcs_aspen_device_invalid_qubit(
        qubit: cirq.Qid, qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice throws error on invalid qubits"""
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    with pytest.raises(UnsupportedQubit):
        device.validate_qubit(qubit)
    with pytest.raises(UnsupportedQubit):
        device.validate_operation(cirq.I(qubit))
Пример #9
0
def test_rigetti_qcs_aspen_device_repr(
        qcs_aspen8_isa: InstructionSetArchitecture):
    """test RigettiQCSAspenDevice.__repr__"""
    device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa)
    assert f'cirq_rigetti.RigettiQCSAspenDevice(isa={qcs_aspen8_isa!r})' == repr(
        device)