Skip to content

Fix segfault in LexiRoute lookahead on classical vertices - #2248

Merged
cqc-alec merged 1 commit into
Quantinuum:mainfrom
cleitonaugusto:fix/2180-classical-vertex-in-next-2qb-slice
Oct 1, 2026
Merged

cqc-alec merged 1 commit into
Quantinuum:mainfrom
cleitonaugusto:fix/2180-classical-vertex-in-next-2qb-slice

Conversation

@cleitonaugusto

Copy link
Copy Markdown
Contributor

Description

MappingFrontier::advance_next_2qb_slice walks the vertices of the next cut and,
for any vertex that does not have more than one quantum in-edge, reads
in_edges[0]. A ClExprOp is purely classical and has no quantum in-edges, so
that read goes past the end of an empty vector. It only crashes some of the time,
which matches the reports in the issue.

Building the original file with -D_GLIBCXX_ASSERTIONS makes it abort at
std::vector::operator[](__n=0) called from MappingFrontier.cpp:265.

The fix skips vertices that don't have exactly one quantum in-edge. A classical
vertex has no qubit boundary to move, and this function is only used for the
lookahead when LexiRoute scores swaps (the boundary is restored afterwards), so
skipping it doesn't change what gets routed.

Tests:

  • New C++ scenario in test_LexiRoute.cpp and a pytket test in mapping_test.py
    with the circuit from the issue. The pytket test segfaults without the fix.
  • Full pytket suite passes locally.
  • I also routed 1000 random circuits with ClExprOps and conditionals on a line
    architecture and checked that each qubit and bit sees the same operations in
    the same order after undoing the swaps. No differences.

Bumped TKET_VERSION to 2.1.102.

Related issues

Fixes #2180.

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation. (no API change)
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

advance_next_2qb_slice read in_edges[0] for every vertex in the next cut
that did not have more than one quantum in-edge. A ClExprOp has none, so
this read past the end of an empty vector.

Skip vertices that do not have exactly one quantum in-edge. Fixes Quantinuum#2180.
@cleitonaugusto
cleitonaugusto marked this pull request as ready for review September 30, 2026 22:45
@cqc-alec
cqc-alec self-requested a review October 1, 2026 07:09

@cqc-alec cqc-alec 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!

@cqc-alec
cqc-alec merged commit 2d03cce into Quantinuum:main Oct 1, 2026
33 of 34 checks passed
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.

Segfault when running DefaultMappingPass

2 participants