Skip to content

Support multiple logical observables and error decomposition in qec_memory decoding - #501

Open
eliottrosenberg wants to merge 4 commits into
quantumlib:mainfrom
eliottrosenberg:qec_multi_obs
Open

eliottrosenberg wants to merge 4 commits into
quantumlib:mainfrom
eliottrosenberg:qec_multi_obs

Conversation

@eliottrosenberg

@eliottrosenberg eliottrosenberg commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Updates get_logical_error_probability to support multiple logical observables.

@eliottrosenberg
eliottrosenberg marked this pull request as ready for review November 8, 2026 21:39
@mhucka
mhucka self-requested a review November 8, 2026 23:31
Comment thread recirq/serialization_utils_test.py Resolved

@mhucka mhucka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. Some comments follow.

Comment thread recirq/qec_memory/decoding_test.py Resolved
Comment thread recirq/qec_memory/decoding.py Resolved
Comment thread recirq/qec_memory/decoding.py Resolved

@mhucka mhucka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! We're almost there :-)

In addition to the minor items noted in the individual comments, can you also please update the PR description? It still says only that "Updates get_logical_error_probability to support multiple logical observables." It would be appropriate to also mention:

  • the new keyword-only arguments per_observable and decompose_errors
  • the return type is now float | np.ndarray
  • zero observables now raises ValueError, and more than one is no longer rejected (previously NotImplementedError)

(This matters because a squash merge uses the PR description as the commit message.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add an assertion with per_observable=True in test_get_logical_error_probability involving 1 observable, to verify that it returns a 1D np.ndarray of shape (1,) rather than squeezing to a scalar?

)
assert isinstance(joint_lep, float)
assert per_obs_lep.shape == (2,)
assert np.max(per_obs_lep) <= joint_lep <= np.sum(per_obs_lep)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this last test succeed for any Boolean matrix? If so, it would pass even if something went wrong with the preceding calculations.

Args:
hardware_stim_circuit: The circuit that was run on hardware, converted to a stim circuit.
si_1000_error_rate: The parameter p in stimflow.NoiseModel.si1000.
decompose_errors: Whether to decompose errors into graphlike components.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be useful to add an explanation of why this matters, and what values to use in what circumstances. Something that brings up the fact that PyMatching ignores error mechanisms with more than two detection events unless they are decomposed, so True would be appropriate for surface codes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the 13-item keys list now appears three times in this file. It would be a good idea to make it into a module-level constant to remove the copies and make it clear that they are all meant to be the same.

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

Successfully merging this pull request may close these issues.

2 participants