Using predefined hardware models¶
The QLM comes with predefined hardware models, in addition to the generic hardware models that one can define using Kraus operators, and to the "perfect" hardware model, DefaultHardwareModel.
Let us show how to use these hardware models. We first construct a circuit that we want to execute on a noisy QPU.
In [1]:
import numpy as np
from itertools import product
from qat.lang.AQASM import Program, H, PH, CNOT, SWAP, RX
prog = Program()
reg = prog.qalloc(2)
prog.apply(H, reg[0])
prog.apply(CNOT, reg)
prog.apply(RX(0.3), reg[0])
prog.apply(RX(0.5), reg[1])
circ = prog.to_circ()
circ.display()
Let us first execute the circuit on a perfect QPU:
In [2]:
from qat.qpus import LinAlg
qpu_0 = LinAlg()
results = qpu_0.submit(circ.to_job())
for sample in results:
print(sample.state, sample.probability)
|00> 0.42417667733679126 |01> 0.07582332266320863 |10> 0.07582332266320863 |11> 0.42417667733679126
Depolarizing noise model¶
Let us now create a depolarizing noise model, and execute the circuit:
In [3]:
from qat.hardware import make_depolarizing_hardware_model
hw_model = make_depolarizing_hardware_model(eps1=0.001, eps2=0.01)
from qat.qpus import NoisyQProc
qpu = NoisyQProc(hardware_model=hw_model)
results = qpu.submit(circ.to_job())
for sample in results:
print(sample.state, sample.probability)
|00> 0.42066173584304295 |01> 0.07933826415695669 |10> 0.07933826415695669 |11> 0.42066173584304295
Here, the numbers 0.001 and 0.01 correspond to the average one- and two-qubit error rates. The function make_depolarizing_hardware_model converts them to depolarization probabilities.
In [ ]: