Avoid overlapping MPP ancilla coordinates#238
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #238 +/- ##
==========================================
- Coverage 86.41% 86.38% -0.04%
==========================================
Files 31 31
Lines 5086 5111 +25
Branches 903 908 +5
==========================================
+ Hits 4395 4415 +20
- Misses 488 491 +3
- Partials 203 205 +2 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6df8025277
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not any(math.dist(coordinate, occupied) <= _COORDINATE_TOLERANCE for occupied in occupied_coordinates): | ||
| return coordinate |
There was a problem hiding this comment.
Check occupancy in the XY plane
When an inferred MPP ancilla shares the displayed data-plane position with an existing node but differs in z, this full 3D math.dist check treats the centroid as unoccupied and returns it unchanged. For example, a Type-I single-qubit Y support infers an ancilla at (x, y, 0.5) between data nodes at (x, y, 0) and (x, y, 1); visualize() projects 3D coordinates to XY, so all three nodes still render on top of each other despite the new placement rule. The occupancy and clearance tests should compare XY distance while preserving the inferred z coordinate.
Useful? React with 👍 / 👎.
Summary
Root cause
MPP ancillas without explicit coordinates were always assigned the component-wise centroid of their connected data nodes. The builder did not check whether another graph node already occupied that coordinate, so nodes could render on top of one another.
Impact
Coordinate-aware MPP imports now remain visually distinguishable when a support centroid coincides with a data qubit or another previously positioned node. Graph construction and temporal placement semantics are unchanged.
Validation
python -m pytest -s -q— 797 passed, 1 skippedruff format --check graphqomb/qec/qeccode.py tests/test_qec.pyruff check graphqomb/qec/qeccode.py tests/test_qec.pymypy graphqomb/qec/qeccode.py tests/test_qec.pypyright graphqomb/qec/qeccode.py tests/test_qec.py