pyGSTi icon indicating copy to clipboard operation
pyGSTi copied to clipboard

MirrorRBDesign samples back-to-back 2Q gate layers

Open sserita opened this issue 2 years ago • 1 comments

Describe the bug MirrorRBDesign occasionally samples circuits with back-to-back 2Q gates (and does so non-deterministically, even when a seed is passed).

To Reproduce

import pygsti
from pygsti.modelpacks import smq1Q_XYI, smq2Q_XYZICNOT
from pygsti.extras import devices
import qiskit
import time
 
from pygsti.processors import QubitProcessorSpec as QPS
from pygsti.processors import CliffordCompilationRules as CCR
from pygsti.baseobjs import QubitGraph as QG
import numpy as np

n_qubits = 5
qubit_labels = ['Q'+str(i) for i in range(n_qubits)]
 
gate_names = ['Gzr', 'Gczr'] + [f'Gc{i}' for i in range(23)]
availability = {'Gczr':[('Q0','Q1'), ('Q1','Q2'), ('Q1','Q3'), ('Q3','Q4')]}
 
connectivity = np.array([[0, 1, 0, 0, 0],
                         [1, 0, 1, 1, 0],
                         [0, 1, 0, 0, 0],
                         [0, 1, 0, 0, 1],
                         [0, 0, 0, 1, 0]], dtype=bool)
graph = QG(qubit_labels=qubit_labels, initial_connectivity=connectivity)
 
pspec = QPS(n_qubits, gate_names, availability=availability, qubit_labels=qubit_labels, geometry=graph)

depths = [0, 2,]# 4, 8, 16, 32, 64, 128, 256] # depths to run MRB
k = 1 # number of samples at each depth
 
sampler = 'edgegrab'
samplerargs = [0.4]
 
mrb_design = pygsti.protocols.MirrorRBDesign(pspec,
                                             depths,
                                             k,
                                             seed=123,
                                             qubit_labels=qubit_labels,
                                             sampler=sampler,
                                             samplerargs=samplerargs,
                                             circuit_type="cz(theta)+zxzxz-haar")

qasm = mrb_design.circuit_lists[1][0].convert_to_openqasm()
 
circ = qiskit.QuantumCircuit.from_qasm_str(qasm)
circ.draw("mpl")

Expected behavior

  1. There are no subsequent 2-qubit gate layers
  2. The sampling is deterministic

Environment (please complete the following information):

  • pyGSTi commit 5922a1f66b2b1bb001012ddc58ebcbc4ec4cc382
  • qiskit 0.36.1
  • python 3.8
  • OSX 11.6

sserita avatar Aug 02 '22 23:08 sserita

This should hopefully fixed by PR #243, and I'll handle the RNG bug as part of a bigger fix with Issue #253. Will close this issue with the next release.

sserita avatar Aug 23 '22 18:08 sserita

Closed as this is now in 0.9.11 release

sserita avatar May 17 '23 06:05 sserita