Skip to content

Commit

Permalink
Hotfix: sample_failures when continuing from file (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSerraPeralta authored Sep 18, 2024
1 parent e7f5a6d commit 195c78a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qec_util/performance/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ def sample_failures(
if "decode_batch" not in dir(decoder):
raise TypeError("'decoder' does not have a 'decode_batch' method.")

sampler = dem.compile_sampler()
num_failures, num_samples = 0, 0
if (file_name is not None) and pathlib.Path(file_name).exists():
num_failures, num_samples = read_failures_from_file(file_name)
# update the maximum limits based on the already calculated samples
# to ease the estimation of the batch size
max_samples -= num_samples
max_failures -= num_failures
# check if desired samples/failures have been reached
if (max_samples <= 0) or (max_failures <= 0):
return num_failures, num_samples

sampler = dem.compile_sampler()
num_failures, num_samples = 0, 0

# estimate the batch size for decoding
defects, log_flips, _ = sampler.sample(shots=100)
t_init = time.time()
Expand Down

0 comments on commit 195c78a

Please sign in to comment.