Skip to content

Commit

Permalink
Merge pull request #28 from quantumgizmos/lsd-goes-ckt-noise
Browse files Browse the repository at this point in the history
Lsd goes ckt noise
  • Loading branch information
quantumgizmos authored Jan 30, 2024
2 parents 33c2cd6 + c94ed2c commit b2273e8
Show file tree
Hide file tree
Showing 9 changed files with 1,637 additions and 16 deletions.
41 changes: 29 additions & 12 deletions examples/sinter_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import sinter
from ldpc.sinter_decoders import SinterBeliefFindDecoder, SinterBpOsdDecoder
import stim
from ldpc.sinter_decoders import SinterBeliefFindDecoder, SinterBpOsdDecoder
from matplotlib import pyplot as plt
import numpy as np


def generate_example_tasks():
Expand All @@ -28,22 +28,31 @@ def generate_example_tasks():


def main():
from src_python.ldpc.sinter_decoders.sinter_lsd_decoder import SinterLsdDecoder
samples = sinter.collect(
num_workers=10,
max_shots=20_000,
max_errors=100,
tasks=generate_example_tasks(),
decoders=['bposd', 'belief_find'],
custom_decoders={'bposd': SinterBpOsdDecoder(
max_iter=5,
bp_method="ms",
ms_scaling_factor=0.625,
schedule="parallel",
osd_method="osd0"),
"belief_find": SinterBeliefFindDecoder(max_iter=5,
decoders=['bposd', 'belief_find', 'bplsd'],
custom_decoders={
'bposd': SinterBpOsdDecoder(
max_iter=10,
bp_method="ms",
ms_scaling_factor=0.625,
schedule="parallel",
osd_method="osd0"),
"belief_find": SinterBeliefFindDecoder(max_iter=10,
bp_method="ms",
ms_scaling_factor=0.625,
schedule="parallel")},
schedule="parallel"),
'bplsd': SinterLsdDecoder(
max_iter=2,
bp_method="ms",
ms_scaling_factor=0.625,
schedule="parallel",
lsd_order=0),
},

print_progress=True,
save_resume_filepath=f'bposd_surface_code.csv',
Expand All @@ -55,7 +64,7 @@ def main():
print(sample.to_csv_line())

# Render a matplotlib plot of the data.
fig, axis = plt.subplots(1, 2, sharey=True, figsize=(10, 5))
fig, axis = plt.subplots(1, 3, sharey=True, figsize=(10, 5))
sinter.plot_error_rate(
ax=axis[0],
stats=samples,
Expand All @@ -71,9 +80,17 @@ def main():
filter_func=lambda stat: stat.decoder == 'belief_find',
x_func=lambda stat: stat.json_metadata['p'],
)
sinter.plot_error_rate(
ax=axis[2],
stats=samples,
group_func=lambda stat: f"Rotated Surface Code d={stat.json_metadata['d']}",
filter_func=lambda stat: stat.decoder == 'lsd',
x_func=lambda stat: stat.json_metadata['p'],
)
axis[0].set_ylabel('Logical Error Rate')
axis[0].set_title('BPOSD')
axis[1].set_title('Belief Find')
axis[2].set_title('LSD')
for ax in axis:
ax.loglog()
ax.grid()
Expand Down
7 changes: 3 additions & 4 deletions src_python/ldpc/bplsd_decoder/_bplsd_decoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ cdef class BpLsdDecoder(BpDecoderBase):
def __cinit__(self, pcm: Union[np.ndarray, scipy.sparse.spmatrix], error_rate: Optional[float] = None,
error_channel: Optional[List[float]] = None, max_iter: Optional[int] = 0, bp_method: Optional[str] = 'minimum_sum',
ms_scaling_factor: Optional[float] = 1.0, schedule: Optional[str] = 'parallel', omp_thread_count: Optional[int] = 1,
random_schedule_seed: Optional[int] = 0, serial_schedule_order: Optional[List[int]] = None, bits_per_step:int = 1, input_vector_type: str = "syndrome", lsd_order: int = 0):
random_schedule_seed: Optional[int] = 0, serial_schedule_order: Optional[List[int]] = None,
bits_per_step:int = 1, input_vector_type: str = "syndrome", lsd_order: int = 0):
self.MEMORY_ALLOCATED=False
self.lsd = new lsd_decoder_cpp(self.pcm[0])
self.bplsd_decoding.resize(self.n) #C vector for the bf decoding
Expand Down Expand Up @@ -133,6 +134,4 @@ cdef class BpLsdDecoder(BpDecoderBase):
out = np.zeros(clss.size(),dtype=int)
for i in range(clss.size()):
out[i] = clss[i]
return out

return self.lsd.cluster_size_stats
return out
Loading

0 comments on commit b2273e8

Please sign in to comment.