import numpy as np
import pygsti
from pygsti import algorithms
n_1 = 4
glist = ['Gx','Gy','Gcnot']
pspec_1 = pygsti.obj.ProcessorSpec(n_1,glist,verbosity=0)
s_1, p_1 = pygsti.symplectic.random_clifford(n_1)
circuit = algorithms.compile_clifford(s_1,p_1,pspec_1)
print(circuit.twoqubit_gatecount())
12
circuit = algorithms.compile_stabilizer_state(s_1,p_1,pspec_1)
print(circuit.twoqubit_gatecount())
4
circuit = algorithms.compile_stabilizer_measurement(s_1,p_1,pspec_1)
print(circuit.twoqubit_gatecount())
4
from pygsti.extras import rb
circuit, out = rb.sample.direct_rb_circuit(pspec_1,10,randomizeout=True)
print(circuit)
print(out)
Qubit 0 ---|Gy |-|Gx |-|Gx |-| |-| |-| |-| |-|Gx |-Gcnot:0:3|-|Gcnot:3:0|-||Gx |-Gcnot:2:0|-||Gy |-Gcnot:0:2|-||Gy |-|Gy |-|Gx |-|Gy |-|Gy |-|Gx |-|Gy |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:3:0|-||Gy |-|Gx |--- Qubit 1 ---|Gy |-|Gx |-|Gx |-| |-| |-| |-| |-|Gy |-Gcnot:1:2|-||Gx |-Gcnot:3:1|-||Gy |-|Gy |-|Gy |-|Gx |-Gcnot:1:3|-||Gy |-|Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-| |-| |--- Qubit 2 ---|Gx |-|Gy |-Gcnot:3:2|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:1:2|-||Gx |-|Gy |-Gcnot:2:0|-|Gcnot:3:2|-|Gcnot:0:2|-||Gx |-|Gx |-Gcnot:3:2|-||Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |--- Qubit 3 ---|Gx |-|Gy |-Gcnot:3:2|-||Gy |-|Gy |-| |-| |-|Gy |-Gcnot:0:3|-|Gcnot:3:0|-|Gcnot:3:1|-||Gy |-Gcnot:3:2|-||Gx |-|Gy |-Gcnot:1:3|-|Gcnot:3:2|-||Gy |-|Gy |-|Gx |-|Gy |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:3:0|-||Gy |-|Gx |--- [1, 0, 0, 1]
from pygsti.extras import rb
circuit, out = rb.sample.clifford_rb_circuit(pspec_1,10,randomizeout=False)
print(circuit)
print(out)
Qubit 0 ---|Gy |-Gcnot:0:3|-||Gx |-|Gy |-|Gx |-Gcnot:3:0|-||Gx |-|Gy |-Gcnot:1:0|-|| |-| |-Gcnot:0:1|-|| |-Gcnot:1:0|-||Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:3|-|Gcnot:2:0|-|| |-| |-| |-| |-| |-Gcnot:0:2|-|| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-||Gy |-Gcnot:3:0|-||Gy |-Gcnot:3:0|-||Gx |-|Gx |-|Gy |-|Gy |-|Gx |-Gcnot:0:2|-|| |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:2|-|| |-| |-| |-Gcnot:2:0|-|| |-| |-|Gx |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|Gcnot:0:2|-|| |-| |-| |-| |-Gcnot:2:0|-|| |-Gcnot:0:3|-|| |-| |-| |-|Gy |-|Gy |-| |-| |-|Gx |-| |-Gcnot:1:0|-|Gcnot:0:1|-|Gcnot:0:2|-|Gcnot:2:0|-|Gcnot:0:2|-|| |-Gcnot:0:3|-|| |-| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-Gcnot:0:3|-|| |-Gcnot:0:3|-|Gcnot:2:0|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:1|-|| |-| |-| |-Gcnot:3:0|-||Gx |-|Gx |-| |-| |-| |-| |-Gcnot:2:0|-||Gy |-Gcnot:2:0|-|| |-Gcnot:3:0|-|| |-| |-| |-| |-| |-Gcnot:3:0|-|Gcnot:1:0|-|| |-| |-Gcnot:0:1|-|| |-| |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-Gcnot:0:3|-||Gy |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:3|-|Gcnot:0:2|-|| |-| |-Gcnot:2:0|-||Gy |-|Gy |-| |-| |-| |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-| |-| |-| |-| |-Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:0:2|-||Gy |-Gcnot:1:0|-|| |-| |-| |-Gcnot:1:0|-||Gy |-|Gy |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:2|-||Gy |-|Gx |-Gcnot:2:0|-||Gy |-Gcnot:1:0|-|Gcnot:2:0|-||Gx |-|Gy |-Gcnot:0:1|-|Gcnot:0:3|-||Gx |-|Gx |-|Gy |-|Gy |--- Qubit 1 ---|Gy |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-||Gy |-|Gx |-Gcnot:0:1|-|Gcnot:1:3|-|Gcnot:1:0|-|| |-| |-| |-| |-|Gx |-|Gy |-|Gx |-Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-| |-| |-| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:3|-||Gy |-|Gx |-Gcnot:1:2|-||Gy |-| |-|Gx |-|Gx |-| |-| |-|Gx |-|Gy |-Gcnot:3:1|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-| |-Gcnot:2:1|-|| |-| |-| |-|Gy |-Gcnot:1:0|-||Gx |-|Gy |-|Gx |-Gcnot:0:1|-|| |-| |-Gcnot:1:2|-|Gcnot:3:1|-|| |-Gcnot:1:3|-|| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:2:1|-|Gcnot:1:0|-|Gcnot:0:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:3:1|-|| |-| |-|Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:2|-||Gy |-Gcnot:3:1|-||Gy |-Gcnot:0:1|-|Gcnot:3:1|-||Gy |-Gcnot:1:3|-|Gcnot:1:2|-||Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-||Gy |-Gcnot:2:1|-|Gcnot:0:1|-||Gy |-Gcnot:2:1|-||Gx |-|Gy |-Gcnot:1:2|-|Gcnot:1:0|-||Gx |-|Gx |-| |-| |-|Gx |-| |-Gcnot:1:3|-|| |-| |-Gcnot:1:0|-|Gcnot:1:2|-|| |-| |-| |-Gcnot:3:1|-|| |-| |-| |-|Gy |-|Gy |-| |-| |-|Gx |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|Gcnot:2:1|-|| |-Gcnot:1:2|-|Gcnot:2:1|-|Gcnot:1:2|-|Gcnot:2:1|-|| |-| |-| |-| |-Gcnot:1:0|-|| |-Gcnot:1:3|-|| |-| |-Gcnot:3:1|-|| |-|Gx |-|Gx |-| |-| |-|Gy |-| |-| |-| |-| |-| |-Gcnot:1:3|-|| |-Gcnot:1:0|-|Gcnot:3:1|-||Gy |-Gcnot:1:3|-|Gcnot:1:0|-|| |-| |-| |-| |-| |-Gcnot:1:2|-|| |-Gcnot:1:2|-|Gcnot:3:1|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:1:0|-|| |-| |-| |-Gcnot:0:1|-|| |-| |-| |-| |-| |--- Qubit 2 ---| |-| |-| |-| |-| |-| |-Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-|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:3|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gx |-| |-Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-Gcnot:0:2|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gx |-Gcnot:1:2|-||Gy |-Gcnot:1:2|-||Gy |-Gcnot:3:2|-|| |-| |-| |-Gcnot:2:3|-|Gcnot:0:2|-|| |-| |-Gcnot:2:0|-|| |-| |-Gcnot:2:0|-|| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |--- Qubit 3 ---|Gx |-Gcnot:0:3|-|| |-| |-| |-Gcnot:3:0|-|Gcnot:3:2|-|Gcnot:2:3|-|| |-| |-| |-| |-Gcnot:1:3|-|| |-| |-| |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-|| |-| |-| |-| |-Gcnot:3:2|-|| |-| |-| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-Gcnot:3:2|-||Gy |-Gcnot:2:3|-||Gy |-Gcnot:2:3|-||Gx |-|Gy |-Gcnot:1:3|-|Gcnot:0:3|-|| |-Gcnot:3:0|-|| |-Gcnot:3:0|-||Gx |-|Gx |-| |-| |-|Gy |-| |-Gcnot:3:1|-||Gy |-|Gx |-Gcnot:3:2|-|| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:3:1|-||Gy |-Gcnot:1:3|-||Gy |-Gcnot:0:3|-|Gcnot:2:3|-||Gx |-|Gy |-|Gy |-|Gy |-| |-| |-|Gx |-| |-| |-| |-| |-| |-| |-Gcnot:2:3|-|Gcnot:0:3|-||Gy |-Gcnot:2:3|-||Gx |-|Gy |-Gcnot:3:1|-|Gcnot:3:2|-||Gy |-|Gx |-|Gx |-| |-Gcnot:0:3|-||Gy |-Gcnot:0:3|-||Gx |-|Gy |-Gcnot:3:2|-|| |-| |-| |-| |-| |-Gcnot:3:1|-|| |-| |-Gcnot:3:1|-|| |-Gcnot:1:3|-|Gcnot:3:0|-||Gx |-|Gx |-| |-| |-|Gy |-| |-| |-| |-| |-Gcnot:3:2|-|Gcnot:3:0|-||Gy |-Gcnot:2:3|-||Gx |-|Gy |-|Gx |-Gcnot:3:0|-|| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-|Gx |-|Gx |-| |-| |-|Gy |-|Gx |-Gcnot:1:3|-|Gcnot:0:3|-|| |-| |-| |-| |-| |-Gcnot:0:3|-|Gcnot:3:1|-|| |-Gcnot:2:3|-|| |-|Gx |-|Gx |-| |-| |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:3:2|-||Gy |-|Gx |-Gcnot:0:3|-|Gcnot:2:3|-||Gy |-Gcnot:1:3|-||Gx |-|Gy |-Gcnot:3:1|-||Gy |-|Gy |-|Gy |-| |-| |-|Gy |-|Gx |-Gcnot:3:2|-|Gcnot:2:3|-|Gcnot:3:0|-|Gcnot:0:3|-|Gcnot:1:3|-|| |-| |-Gcnot:3:1|-|| |-Gcnot:1:3|-|| |-|Gx |-|Gx |-|Gy |-|Gy |-|Gy |-| |-| |-| |-Gcnot:3:1|-|Gcnot:3:2|-||Gx |-|Gy |-|Gx |-Gcnot:2:3|-||Gx |-|Gy |-| |-| |-| |-| |-| |-| |-| |-| |-Gcnot:0:3|-||Gx |-|Gx |-| |-| |--- [0, 0, 0, 0]
n_2 = 3
glist = ['Gxpi','Gypi','Gzpi','Gh','Gp','Gcphase']
availability = {'Gcphase':[(0,1),(1,2)]}
pspec_2 = pygsti.obj.ProcessorSpec(n_2,glist,availability=availability,verbosity=0)
n_3 = 6
glist = ['Gxpi','Gypi','Gzpi','Gh','Gp','Gcphase']
availability = {'Gcphase':[(0,1),(1,2),(2,3),(3,4),(4,5)]}
pspec_3 = pygsti.obj.ProcessorSpec(n_3,glist,availability=availability,verbosity=0)
np.sum(pspec_3.qubitgraph.shortest_path_distance_matrix(),axis=0)
s_3, p_3 = pygsti.symplectic.random_clifford(n_3)
circuit = algorithms.compile_clifford(s_3,p_3,pspec_3)
print(circuit.twoqubit_gatecount())
circuit = algorithms.compile_stabilizer_state(s_3,p_3,pspec_3)
print(circuit.twoqubit_gatecount())
pygsti.symplectic.composite_clifford_from_clifford_circuit(circuit,)
g= pspec_1.models['clifford']
l = []
if l == None:
print(1)