Skip to content

Conversation

@LSHerzog
Copy link
Collaborator

@LSHerzog LSHerzog commented Mar 31, 2025

Description

Adds features to perform macroscopic lattice surgery compilation for the color code. Both a routing for CNOT+T gates as well as a hill climbing based qubit label optimization is included. Furthermore, the microscopic construction of the snakes' stabilizers (for long distance lattice surgery) is provided both for the color code and surface code substrate.

Basic usage and how to reproduce benchmarks is described here.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation. (At least a few tests and a rst file with the most important information)
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

pre-commit-ci bot and others added 4 commits April 7, 2025 14:50
## Description

This PR removes the C++ part of the package since it is no longer
actively developed, and its features have largely been replaced by other
libraries.

In particular, this removes the following features:

- C++ implementation of the union-find QLDPC decoder.
[ldpc](https://github.com/quantumgizmos/ldpc) is actively maintained and
developed for a dedicated package.
- Applying error correction to quantum circuits. This functionality is
mostly deprecated, not actively developed and no future work is planned.

This also removes the necessary CI. 

This PR also updates the documentation to use `myst` and builds the
Python documentation using [sphinx
autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#module-sphinx.ext.autodoc).

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.

---------

Signed-off-by: burgholzer <burgholzer@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: burgholzer <burgholzer@me.com>
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Collaborator

@pehamTom pehamTom left a comment

Choose a reason for hiding this comment

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

Ok, so I finished my review until snake_builder.py. Since this is quite a large contribution I would give you the first chunk already and look at the rest later. If some of my questions are resolved by looking at the rest of the code then just ignore them.

The code looks good to me, I just added some suggestions, comments and questions where I thought some things could be improved.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are both the rst and the md file in the docs now. I guess the rst file can be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In principle yes. The rst file is just used as intermediate solution as long as this branch is not merged into main. However, the main branch's readme currently links to this rst file, which is why I would like to keep it for now. I would delete it as soon as we merge my branch into main.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then I'll leave this comment open until that time so we don't forget.

Comment on lines +1022 to +1029
def compatible_x_stabs() -> list[dict[str, list[int]]]:
"""Returns the allowed Weight 8 X Stabilizers crossing Steane patches."""
return [
{"i": [0, 2, 4, 6], "i+1": [0, 2, 4, 6]},
{"i": [3, 4, 5, 6], "i+1": [1, 2, 5, 6]},
{"i": [3, 4, 5, 6], "i+1": [0, 2, 4, 6]},
{"i": [1, 2, 5, 6], "i+1": [1, 2, 5, 6]},
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this have to be a list of dicts instead of a list of tuples?

Comment on lines +1031 to +1044
@staticmethod
def compatible_z_stabs_weight_two() -> list[dict[str, int]]:
"""Returns allowed weight-2 z stabilizer connections."""
return [
{"i": 1, "i+1": 1},
{"i": 0, "i+1": 0},
{"i": 3, "i+1": 1},
{"i": 1, "i+1": 3},
{"i": 3, "i+1": 0},
{"i": 0, "i+1": 3},
{"i": 1, "i+1": 0},
{"i": 0, "i+1": 1},
]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above.


return None

def translate_checks(self) -> tuple[list[list[int]], list[list[int]]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is some inconsistency here. We have gen_checks, gen_check_matrix and translate_checks in the different classes, respectively.

Also is there a reason these are lists instead of numpy arrays?

plt.show()


def convex_hull(points: list[tuple[float, float]]) -> list[tuple[float, float]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity: Is this a version of the Graham Scan 😄 ?

LSHerzog and others added 4 commits July 18, 2025 16:59
Signed-off-by: Laura S. Herzog <130370753+LSHerzog@users.noreply.github.com>
@LSHerzog LSHerzog force-pushed the ls-compilation branch 2 times, most recently from 825be09 to 71e9d04 Compare July 19, 2025 14:15

from __future__ import annotations

# from . import plots
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# from . import plots

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.

4 participants