-
Notifications
You must be signed in to change notification settings - Fork 9
Default tolerant zephyr models #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,7 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
| // README at: https://github.com/devcontainers/templates/tree/main/src/debian | ||
| // For format details, see https://aka.ms/devcontainer.json. | ||
| { | ||
| "name": "Ocean Development Environment", | ||
|
|
||
| // python 3.11 on debian, with latest Ocean and optional packages | ||
| // source repo: https://github.com/dwavesystems/ocean-dev-docker | ||
| "image": "docker.io/dwavesys/ocean-dev:latest", | ||
|
|
||
| // install repo pip requirements (only if present) on content update | ||
| "updateContentCommand": "[ ! -r requirements.txt ] || pip install -r requirements.txt", | ||
|
|
||
| // forward/expose container services (relevant only when run locally) | ||
| "forwardPorts": [ | ||
| // dwave-inspector web app | ||
| 18000, 18001, 18002, 18003, 18004, | ||
| // OAuth connect redirect URIs | ||
| 36000, 36001, 36002, 36003, 36004 | ||
| ], | ||
|
|
||
| "portsAttributes": { | ||
| "18000-18004": { | ||
| "label": "D-Wave Problem Inspector", | ||
| "requireLocalPort": true | ||
| }, | ||
| "36000-36004": { | ||
| "label": "OAuth 2.0 authorization code redirect URI", | ||
| "requireLocalPort": true | ||
| } | ||
| }, | ||
|
|
||
| // Configure tool-specific properties. | ||
| "customizations": { | ||
| // Configure properties specific to VS Code. | ||
| "vscode": { | ||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "workbench": { | ||
| "editorAssociations": { | ||
| "*.md": "vscode.markdown.preview.editor" | ||
| }, | ||
| "startupEditor": "readme" | ||
| } | ||
| }, | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-toolsai.jupyter" | ||
| ] | ||
| } | ||
| } | ||
| // Debian stable with the second-latest Python, latest Ocean, and optional dev packages. | ||
| // Docker image source: https://github.com/dwavesystems/ocean-dev-docker. | ||
| // Devcontainer config: https://github.com/dwavesystems/ocean-devcontainer. | ||
| "image": "docker.io/dwavesys/ocean-dev:latest" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <!-- | ||
| Thanks for contributing a pull request! Please ensure that | ||
| your PR conforms to our contributor guide. | ||
| https://github.com/dwave-examples/template-dash/blob/main/CONTRIBUTING.md | ||
| --> | ||
|
|
||
| ### Associated GitHub Issue | ||
| <!--If applicable. Example: Closes https://github.com/dwave-examples/template-dash/issues/X--> | ||
|
|
||
| ### Feature Implemented/Bugs Fixed | ||
| <!--Please explain your changes.--> | ||
|
|
||
| ### Additional Information | ||
| <!--Any additional information you think is important.--> | ||
|
|
||
| ### Accessibility Score | ||
| <!--If the UI was significantly changed, what is the updated accessibility score?--> | ||
|
|
||
| ### AI Generation Disclosure | ||
| <!-- If AI was used in the preparation of this pull request, please disclose | ||
| the tool(s) used, how they were used, and specify what code or text is AI generated. | ||
| If no AI tools were used, please write "No AI tools used" in this section. Read our | ||
| policy on AI generated code at | ||
| https://docs.dwavequantum.com/en/latest/ocean/ai_policy.html --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ | |
| from torchvision.utils import save_image | ||
|
|
||
| from demo_configs import GENERATE_NEW_MODEL_DIAGRAM, GRAPH_COLORS, SHARPEN_OUTPUT, THEME_COLOR_SECONDARY | ||
| from src.utils.common import get_graph_mapping, greedy_get_subgraph | ||
| from src.utils.common import get_graph_mapping, greedy_get_subgraph, _try_zephyr_sublattice_fallback | ||
|
|
||
| MODEL_PATH = Path("models") | ||
| JSON_FILE_DIR = "generated_json" | ||
|
|
@@ -358,13 +358,24 @@ def generate_model_fig( | |
| """ | ||
| qpu = DWaveSampler(solver=qpu) | ||
| qpu_graph = qpu.to_networkx_graph() | ||
| subgraph = greedy_get_subgraph(n_nodes=n_latents, random_seed=random_seed, graph=qpu_graph) | ||
| _, mapping = get_graph_mapping(subgraph) | ||
| qpu_topology = qpu.properties["topology"]["type"] | ||
|
|
||
| latent_mapping = [mapping[node] for node in subgraph.nodes()] | ||
| try: | ||
| subgraph = greedy_get_subgraph(n_nodes=n_latents, random_seed=random_seed, graph=qpu_graph) | ||
| _, mapping = get_graph_mapping(subgraph) | ||
| latent_mapping = [mapping[node] for node in subgraph.nodes()] | ||
| except Exception: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify exception caught, or at least print error message? I assume you're trying to catch a specific error here for when |
||
| if qpu_topology != "zephyr": | ||
| raise | ||
| fallback = _try_zephyr_sublattice_fallback( | ||
| n_nodes=n_latents, qpu_graph=qpu_graph, random_seed=random_seed | ||
| ) | ||
| if fallback is None: | ||
| raise | ||
|
Comment on lines
+369
to
+374
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing exceptions and messages. |
||
| subgraph, _ = fallback | ||
| latent_mapping = list(subgraph.nodes()) | ||
|
|
||
| qpu_shape = qpu.properties["topology"]["shape"][0] | ||
| qpu_topology = qpu.properties["topology"]["type"] | ||
|
|
||
| if qpu_topology == "pegasus": | ||
| node_coords = dnx.drawing.pegasus_layout(dnx.pegasus_graph(qpu_shape), crosses=True) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of not copying this twice, you could:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same below.