예제 #1
0
def demo_adonis(do_measure=False, use_qsim=False):
    """Run the demo using the Adonis architecture."""

    print('\nAdonis demo\n===========\n')
    device = Adonis()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[3];
        creg meas[3];
        U(0.2, 0.5, 1.7) q[1];
        h q[0];
        cx q[2], q[1];
        ising(-0.6) q[0], q[2];  // QASM extension
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q0 = cirq.NamedQubit('q_0')
    q2 = cirq.NamedQubit('q_2')
    circuit.insert(len(circuit) - 1, cirq.CXPowGate(exponent=0.723)(q2, q0))

    demo(device, circuit, do_measure, use_qsim=use_qsim)
예제 #2
0
def demo_valkmusa(do_measure=False, use_qsim=False):
    """Run the demo using the Valkmusa architecture."""

    print('\nValkmusa demo\n=============\n')
    device = Valkmusa()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[2];
        creg meas[2];
        U(1.3, 0.4, -0.3) q[1];
        h q[0];
        rx(1.1) q[0];
        cx q[0], q[1];
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q0 = cirq.NamedQubit('q_0')
    q1 = cirq.NamedQubit('q_1')
    circuit.insert(len(circuit) - 1, cirq.ISwapPowGate(exponent=0.4)(q0, q1))

    qubit_mapping = {'q_0': 'QB1', 'q_1': 'QB2'}
    demo(device, circuit, do_measure, use_qsim=use_qsim, qubit_mapping=qubit_mapping)
예제 #3
0
def demo_apollo(do_measure=False, use_qsim=False):
    """Run the demo using the Apollo architecture."""

    print('\nApollo demo\n===========\n')
    device = Apollo()
    qasm_program = """
        OPENQASM 2.0;
        include "qelib1.inc";
        qreg q[6];
        creg meas[3];
        U(0.2, 0.5, 1.7) q[1];
        h q[0];
        h q[2];
        h q[4];
        h q[5];
        cx q[0], q[1];
        cx q[3], q[4];
    """
    if do_measure:
        qasm_program += '\nmeasure q -> meas;'

    circuit = circuit_from_qasm(qasm_program)

    # add some more gates
    q2 = cirq.NamedQubit('q_2')
    q3 = cirq.NamedQubit('q_3')
    circuit.insert(len(circuit) - 1, cirq.CXPowGate(exponent=0.723)(q2, q3))

    qubit_mapping = {
        'q_0': 'QB1',
        'q_1': 'QB2',
        'q_2': 'QB3',
        'q_3': 'QB4',
        'q_4': 'QB5',
        'q_5': 'QB6'
    }
    demo(device,
         circuit,
         do_measure,
         use_qsim=use_qsim,
         qubit_mapping=qubit_mapping)