Skip to content

Cube embedding#280

Open
mahdiehmalekian wants to merge 1 commit into
dwavesystems:mainfrom
mahdiehmalekian:cube_embedding
Open

Cube embedding#280
mahdiehmalekian wants to merge 1 commit into
dwavesystems:mainfrom
mahdiehmalekian:cube_embedding

Conversation

@mahdiehmalekian

Copy link
Copy Markdown

This PR contains the cube embedder together with the needed tools.

cube_embedding contains perfect_cube_embedding.py which has the cube embedder function for graphs with Zephyr topology.
The rest of cube_embedding folder contains the necessary tools for performing the algorithm.

_lattice_utils contains some tools that can be used for finding the embedding of a variety of lattices (2d or 3d) on Zephyr. These tools are also used in cube_embedding.

@SebastianGitt SebastianGitt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looking good, just did a first pass highlighting mostly minor issues before I take a deeper look. I did find what may be a couple of small bugs.

_fields = ("u", "w", "k", "j")

def to_tuple(self) -> tuple[int]:
"""Rerurns the tuple corresponding to the coordinate."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
"""Rerurns the tuple corresponding to the coordinate."""
"""Returns the tuple corresponding to the coordinate."""

_fields = ("u", "w", "j")

def to_tuple(self) -> tuple[int]:
"""Rerurns the tuple corresponding to the coordinate."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
"""Rerurns the tuple corresponding to the coordinate."""
"""Returns the tuple corresponding to the coordinate."""


Provides convenient representations and helpers for embedding-related algorithms.
Example:
>>> from burnaby.lattice_embedding.auxiliary_coordinates import UWKJ

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
>>> from burnaby.lattice_embedding.auxiliary_coordinates import UWKJ
>>> from minorminer._lattice_utils.auxiliary_coordinates import UWKJ

It captures the full coordinate of a Zephyr node.

Example:
>>> from burnaby.lattice_embedding.auxiliary_coordinates import UWKJZ

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
>>> from burnaby.lattice_embedding.auxiliary_coordinates import UWKJZ
>>> from minorminer._lattice_utils.auxiliary_coordinates import UWKJZ


# To make the node label consistent with ``G``'s
# (i.e. "int" or "coordinates")
if label == "coordinates":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should this be "coordinate" instead of "coordinates"? If so, should add a test using this branch since it wasn't caught

if isinstance(val, int):
copied_dict[var] = val
elif isinstance(val, list):
copied_dict[var] = [k for k in val]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a shallow copy but the docstring says it returns a deep copy

Returns:
dict[Edge, int]: The dictionary after removing all items with value zero.
"""
return {chain: chain_freq for chain, chain_freq in chain_freq.items() if chain_freq != 0}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

chain_freq is used for both the dictionary and the dictionary values, consider renaming one of them to make it more clear

from typing import Generator, NamedTuple

from minorminer.utils.zephyr.node_edge import Edge, NodeKind

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

inconsistent spacing here and elsewhere, I recommend running a code formatter like Black if you haven't already

"""
A helper to represent some information of a path of chains of node indices (within a :class:`QuoTile`).
edge (Edge): Edge of node indices represnting the index-chain
pos (tuple[int, int]): pair of positions, the i-th element representing the number of occurence of i-th element of the index-chain when visiting the index-chain

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should break this up over two lines so it doesn't exceed 100 characters (here and elsewhere)

connectivity checks based on z-coupling.
4. A lattice survey module that provides utilities for embedding lattices
on partially-yielded Zephyr graphs.
5. A qoutient tile object to facilitate embedding lattice-type graphs on Zephyr.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
5. A qoutient tile object to facilitate embedding lattice-type graphs on Zephyr.
5. A quotient tile object to facilitate embedding lattice-type graphs on Zephyr.

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