Analog Jobs

Similarly to quantum circuits, schedules can be turned into jobs using the to_job method:

from qat.core import Variable, Observable, Schedule, Term

t_variable = Variable("t")
schedule = Schedule(drive=(1 - t_variable) * Observable(1, pauli_terms=[Term(1, 'Z', [0])]),
                    tmax=2.0)

# To simply sample the final state in the computational basis
job = schedule.to_job()

# To evaluate some observable at the end of the computation
job = schedule.to_job(observable=Observable(1, pauli_terms=[Term(1, 'Z', [0])]))

This method takes more or less the same arguments as the quantum circuit’s method with the same name. One important difference to notice: it is possible to change the starting state of the computation using the psi_0 argument:

import numpy as np
from qat.core import Variable, Observable, Schedule, Term

t_variable = Variable("t")
schedule = Schedule(drive=(1 - t_variable) * (Observable(2, pauli_terms=[Term(1, 'Z', [0])]) +
                                              Observable(2, pauli_terms=[Term(1, 'Z', [1])])),
                    tmax=2.0)

# Starting from |++> state
job = schedule.to_job(psi_0='++')

# Starting from |+1> state
job = schedule.to_job(psi_0='+1')

# Starting from a random initial state (simulator only)
vec = np.random.random(4)  # 4 states for 2 qubits
vec /= np.linalg.norm(vec)
job = schedule.to_job(psi_0=vec)