Skip to content

Add an example notebook for decoding tqec circuits#445

Open
HaoTy wants to merge 11 commits into
qLDPCOrg:mainfrom
HaoTy:doc/tqec-example-notebook
Open

Add an example notebook for decoding tqec circuits#445
HaoTy wants to merge 11 commits into
qLDPCOrg:mainfrom
HaoTy:doc/tqec-example-notebook

Conversation

@HaoTy
Copy link
Copy Markdown
Collaborator

@HaoTy HaoTy commented Apr 12, 2026

Addresses #402.

MWPM doesn't compile correctly. BP-OSD works, so I tend to think the issue is on the qLDPC side or due to an incompatibility between tqec and qLDPC. @perlinm could you take a look at the MWPM error?

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 13, 2026

IIRC we also had issues with tqec returning non-matchable circuits in arXiv:2511.20947, for which we also needed to use BP-OSD at some point.

I'll take a look at the error, and meanwhile also see whether we can reproduce our old tqec/matching issue with @jmusullivan .

@HaoTy
Copy link
Copy Markdown
Collaborator Author

HaoTy commented Apr 13, 2026

Yeah I also recall, but I don't remember what caused it and how we solved it.

This issue might be different, as the default pymatching in sinter works fine.

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 13, 2026

It's possible that the default pymatching in sinter simply ignores non-graphlike errors. That's what oscarhiggott/PyMatching does if you call Matching.from_detector_error_model instead of Matching.from_check_matrix.

@HaoTy
Copy link
Copy Markdown
Collaborator Author

HaoTy commented Apr 13, 2026

Interesting, I see.

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 19, 2026

Yep, looks like the notebook runs fine (and shows reasonable results) if I run with

custom_decoders = {
    f"{d=}": decoders.SlidingWindowDecoder(
        d,
        d // 2,
        with_MWPM=True,
        ignore_non_graphlike_errors=True,
    )
    for d in distances
}

I flagged this in tqec/tqec#913.

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 19, 2026

Let's go ahead and set ignore_non_graphlike_errors=True for now. Otherwise this looks good to me! I can make minor tweaks for language/style in a follow-up PR.

@perlinm perlinm marked this pull request as ready for review April 19, 2026 16:35
@perlinm perlinm self-requested a review as a code owner April 19, 2026 16:35
@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 19, 2026

I do not understand the installation error in the failed check:

Run uv sync --extra dev
  uv sync --extra dev
  shell: /usr/bin/bash -e {0}
  env:
    UV_PYTHON_INSTALL_DIR: /home/runner/work/_temp/uv-python-dir
    UV_PYTHON: 3.12
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
Resolved 209 packages in 691ms
error: Distribution `stim==1.16.dev1776477515 @ registry+[https://pypi.org/simple`](https://pypi.org/simple%60) can't be installed because it doesn't have a source distribution or wheel for the current platform

hint: You're using CPython 3.12 (`cp312`), but `stim` (v1.16.dev1776477515) only has wheels with the following Python ABI tag: `cp310`
Error: Process completed with exit code 2.

The checks clearly worked for other recent PRs, which used the same github workflow files...

Copy link
Copy Markdown
Collaborator

@perlinm perlinm left a comment

Choose a reason for hiding this comment

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

One minor request

Comment thread examples/logical_error_rates/7_decoding_tqec_circuits.ipynb Outdated
Comment thread examples/logical_error_rates/7_decoding_tqec_circuits.ipynb Outdated
@HaoTy
Copy link
Copy Markdown
Collaborator Author

HaoTy commented Apr 19, 2026

I do not understand the installation error in the failed check:

Run uv sync --extra dev
  uv sync --extra dev
  shell: /usr/bin/bash -e {0}
  env:
    UV_PYTHON_INSTALL_DIR: /home/runner/work/_temp/uv-python-dir
    UV_PYTHON: 3.12
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: .venv
Resolved 209 packages in 691ms
error: Distribution `stim==1.16.dev1776477515 @ registry+[https://pypi.org/simple`](https://pypi.org/simple%60) can't be installed because it doesn't have a source distribution or wheel for the current platform

hint: You're using CPython 3.12 (`cp312`), but `stim` (v1.16.dev1776477515) only has wheels with the following Python ABI tag: `cp310`
Error: Process completed with exit code 2.

The checks clearly worked for other recent PRs, which used the same github workflow files...

This is due to the workflow trying to install stim==1.16.dev1776477515, which is the latest pre-release on PyPI (https://pypi.org/project/stim/1.16.dev1776477515/, 2 days ago) and doesn't have a wheel for 3.12, whereas previously the workflow installed earlier versions of stim that had wheels.

Do you want to place an upper bound on stim for now?

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 19, 2026

Yeah, I think it would be okay to bound or pin the version of Stim for now.

@perlinm perlinm self-requested a review April 19, 2026 19:22
@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 21, 2026

Could we tackle #402 here? Maybe have one example with ordinary decoding and an identical example switching out the decodr, hopefully showing similar logical error rates.

I'd be happy to punt it to a future PR if it's significantly more work than expected.

@HaoTy
Copy link
Copy Markdown
Collaborator Author

HaoTy commented Apr 22, 2026

Could we tackle #402 here? Maybe have one example with ordinary decoding and an identical example switching out the decodr, hopefully showing similar logical error rates.

I'd be happy to punt it to a future PR if it's significantly more work than expected.

It's easy to add, but the ordinary decoding doesn't need to simulate separately for each distance, so the code reuse/repetition won't be very elegant.

@perlinm
Copy link
Copy Markdown
Collaborator

perlinm commented Apr 22, 2026

What do you mean by

the ordinary decoding doesn't need to simulate separately for each distance

?

Each distance corresponds to a different circuit, and in turn a different simulation+decoding problem, no?

@HaoTy
Copy link
Copy Markdown
Collaborator Author

HaoTy commented Apr 22, 2026

What do you mean by

the ordinary decoding doesn't need to simulate separately for each distance

?

Each distance corresponds to a different circuit, and in turn a different simulation+decoding problem, no?

Ah, my phrasing was confusing. I meant that because tqec's simulation interface doesn't support assigning decoders by distance, sliding window decoding needs to call it for each distance, whereas ordinary decoding only needs to call it once for all distances. Anyway, you can take a look at my last commit.

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