Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception handling for noiseless circuits #2

Open
navneethramakrishnan opened this issue Nov 19, 2024 · 0 comments
Open

Exception handling for noiseless circuits #2

navneethramakrishnan opened this issue Nov 19, 2024 · 0 comments

Comments

@navneethramakrishnan
Copy link

navneethramakrishnan commented Nov 19, 2024

For a noiseless Stim circuit, the BPOSD decoder does not decode and instead outputs the error message

IndexError: index 0 is out of bounds for axis 0 with size 0

However, the PyMatching decoder does not have such an error and decodes correctly.

Example code below

import numpy as np
from stimbposd import BPOSD
import pymatching

test_circ = stim.Circuit.generated(
    "repetition_code:memory",
    rounds=25,
    distance=9,
    before_round_data_depolarization=0,
    before_measure_flip_probability=0)

num_shots = 100

sampler = test_circ.compile_detector_sampler()
shots, observables = sampler.sample(num_shots, separate_observables=True)

#decoder = pymatching.Matching.from_detector_error_model(test_circ.detector_error_model(decompose_errors=True))
decoder = BPOSD(test_circ.detector_error_model(), max_bp_iters=20)


predicted_observables = decoder.decode_batch(shots)
num_mistakes = np.sum(np.any(predicted_observables != observables, axis=1))

print(f"{num_mistakes}/{num_shots}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant