The below is an example of how to run some benchmarking routines from within Pyquil. The first is conjugating a Pauli by a Clifford element, and the second is constructing randomized benchmarking sequences.


In [2]:
from pyquil.quil import Program
from pyquil.api import CompilerConnection
from pyquil.gates import CNOT, X,Z, Y, PHASE, H
from pyquil.paulis import PauliTerm
import numpy as np

In [3]:
cc = CompilerConnection()

In [4]:
clifford = Program().inst(X(1000))

In [5]:
pauli = PauliTerm("Y", 1000)

In [6]:
print(cc.apply_clifford_to_pauli(clifford, pauli))


(-1+0j)*Y1000

In [7]:
clifford = Program().inst(X(0), CNOT(0, 1), Y(1), Z(0))

In [8]:
pauli = PauliTerm("Y", 0) * PauliTerm("Z", 1, 1.j)

In [9]:
print(cc.apply_clifford_to_pauli(clifford, pauli))


1j*Y0*X1

In [10]:
gateset_1q = [PHASE(np.pi/2, 0), H(0)]

In [11]:
progs = cc.generate_rb_sequence(100, 1, gateset_1q)

In [12]:
print(progs[0])


H 0
PHASE(pi/2) 0
H 0


In [13]:
len(progs)


Out[13]:
100

In [14]:
gateset_2q = [PHASE(np.pi/2, 0), H(0), CNOT(0, 1), H(1), PHASE(np.pi/2, 1)]

In [15]:
progs_2q = cc.generate_rb_sequence(100, 2, gateset_2q)
print(progs_2q[0])


PHASE(pi/2) 0
CNOT 0 1
H 1
CNOT 0 1
H 0
PHASE(pi/2) 0
H 1
CNOT 0 1
H 0