Skip to content

Add el-geometry - #289

Open
mahdiehmalekian wants to merge 4 commits into
dwavesystems:mainfrom
mahdiehmalekian:clique
Open

Add el-geometry#289
mahdiehmalekian wants to merge 4 commits into
dwavesystems:mainfrom
mahdiehmalekian:clique

Conversation

@mahdiehmalekian

Copy link
Copy Markdown

Introduces a new package tree for clique embedder and adds the first module, el_geometry.py, which implements the pure geometry of the L-shaped ("el") templates used to build clique embeddings on a defected Zephyr graph.

Changes
minorminer/embedders/__init__.py
minorminer/embedders/clique/__init__.py
minorminer/embedders/clique/_zephyr/__init__.py
New module minorminer/embedders/clique/_zephyr/el_geometry.py computes ideal el-template geometry for Zephyr. All functions are k-agnostic (quotient) and depend only on the Zephyr grid size m and the ideal topology, not on the tile size t or on which nodes/edges a specific graph contains. Uses Zephyr Cartesian (x, y, k) coordinates following dwave.graphs.ZephyrCartesianCoord.

Matching tests:
tests/embedders/__init__.py, tests/embedders/clique/__init__.py, tests/embedders/clique/zephyr/__init__.py,
tests/embedders/clique/zephyr/test_el_geometry.py

Note
This is the first piece of a larger Zephyr clique-embedder effort; it lands the geometry layer only, with no public API wired up yet.

AI use
Used AI to clean up my code and complete, edit documentation. Also used it to write the test suite. Checked and edited everything myself.

@mahdiehmalekian

Copy link
Copy Markdown
Author

While this module works with the concept of Zephyr Cartesian coordinates introduced in dwavesystems/dwave-graphs#275, this module is independent of that PR.

@mahdiehmalekian

mahdiehmalekian commented Jul 30, 2026

Copy link
Copy Markdown
Author

Note to reviewers: This is the first of a series. Subsequent clique-embedder PRs depend on this PR and can only follow once this merges. So would much appreciate a speedy review.

@mahdiehmalekian mahdiehmalekian changed the title Add embedders/clique/_zephyr with el-geometry Add el-geometry Jul 31, 2026
@mahdiehmalekian

Copy link
Copy Markdown
Author

Undid the creation of embedders directory and moved el_geometry.py from embedders/clique/_zephyr to utils/_clique per Slack discussion

Comment thread minorminer/utils/_clique/el_geometry.py
Comment thread tests/utils/clique/test_el_geometry.py Outdated
Comment thread tests/utils/clique/test_el_geometry.py Outdated
x_sign = 1 if v_x > h_x else -1
y_sign = 1 if h_y > v_y else -1
hp_x = v_x - x_sign if (x_diff & 3) == 1 else v_x + x_sign
if hp_x < 0 or hp_x > abs_max:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be worthwhile to have some additional input validation, such as ensuring v_x and v_y have opposite parity.

@mahdiehmalekian mahdiehmalekian Aug 11, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For this module, performance is the top priority. And this parity check will be ensured in the caller (to come in a subsequent PR) of this function.

Comment thread minorminer/utils/_clique/el_geometry.py Outdated
Comment thread tests/utils/clique/test_el_geometry.py Outdated


class TestElbow(unittest.TestCase):
# (m, vx, vy, hx, hy, expected): expected is the (vp_y, hp_x) elbow, or None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would use a docstring here instead (and for the rest of the classes)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That is a comment for its following list, not for the class. Also, for the rest of such instances. I put a blank line between class definition and such comments in a527edc to make this clear.

Comment thread minorminer/utils/_clique/el_geometry.py Outdated
Comment thread tests/utils/clique/test_el_geometry.py Outdated
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.

3 participants