Skip to content

Default tolerant zephyr models#33

Open
k8culver wants to merge 3 commits into
mainfrom
feature/default-tollerant
Open

Default tolerant zephyr models#33
k8culver wants to merge 3 commits into
mainfrom
feature/default-tollerant

Conversation

@k8culver

Copy link
Copy Markdown
Contributor

Feature Implemented

Losing a qubit from the Advantage2 typically renders the models (trained on the Advantage2) unusable. The changes in this PR allow for these models to continue to be used even after a qubit or two has been lost.

Note: The Advantage2 models in this branch are old and have not been updated to the new models. These models were trained prior to the last qubit loss and therefore should be helpful for testing.

AI Generation Disclosure

Copilot was given the fully_yielded_zephyr_subgraph file and implemented this guided but mostly unaided. I have reviewed it and tested it. Please review carefully.

@jackraymond

Copy link
Copy Markdown

Proof of concept that this works is already finished, IP approved and discussed publicly 2026-06-24-AQC-Jack Raymond.pptx . Codebase is already in public pull request dwavesystems/dwave-experimental#54. Just some differences in the training and archiecture conventions to understand (and test).

@jackraymond

Copy link
Copy Markdown

Since this pull request was made there have been some method developments relative to fully_yielded_zephyr_subgraph. That need to be incorporated

@thisac thisac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart for some minor comments, LGTM. Would be good to have someone more familiar with the defect zephyr subgraph embedding implementation to review and approve before merging though.

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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 greedy_get_subgraph fails for find a subgraph?

Comment on lines +369 to +374
raise
fallback = _try_zephyr_sublattice_fallback(
n_nodes=n_latents, qpu_graph=qpu_graph, random_seed=random_seed
)
if fallback is None:
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing exceptions and messages.

Comment thread src/model_wrapper.py
Comment on lines +310 to +328
try:
samples = self._grbm.sample( # type: ignore
sampler=self.sampler,
prefactor=self.PREFACTOR,
linear_range=self.linear_range,
quadratic_range=self.quadratic_range,
device=spins.device,
sample_params=self.sampler_kwargs,
)
except BinaryQuadraticModelStructureError:
self._rebuild_sampler()
samples = self._grbm.sample( # type: ignore
sampler=self.sampler,
prefactor=self.PREFACTOR,
linear_range=self.linear_range,
quadratic_range=self.quadratic_range,
device=spins.device,
sample_params=self.sampler_kwargs,
)

Copy link
Copy Markdown
Contributor

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:

Suggested change
try:
samples = self._grbm.sample( # type: ignore
sampler=self.sampler,
prefactor=self.PREFACTOR,
linear_range=self.linear_range,
quadratic_range=self.quadratic_range,
device=spins.device,
sample_params=self.sampler_kwargs,
)
except BinaryQuadraticModelStructureError:
self._rebuild_sampler()
samples = self._grbm.sample( # type: ignore
sampler=self.sampler,
prefactor=self.PREFACTOR,
linear_range=self.linear_range,
quadratic_range=self.quadratic_range,
device=spins.device,
sample_params=self.sampler_kwargs,
)
for _ in range(2):
try:
samples = self._grbm.sample( # type: ignore
sampler=self.sampler,
prefactor=self.PREFACTOR,
linear_range=self.linear_range,
quadratic_range=self.quadratic_range,
device=spins.device,
sample_params=self.sampler_kwargs,
)
except BinaryQuadraticModelStructureError:
self._rebuild_sampler()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same below.

Comment thread src/utils/common.py
Comment on lines +236 to +250
try:
subgraph = greedy_get_subgraph(n_nodes=n_latents, random_seed=random_seed, graph=qpu_graph)
mapped_graph, mapping = get_graph_mapping(subgraph)
sampler = FixedEmbeddingComposite(qpu, {l_: [p] for p, l_ in mapping.items()})
except Exception:
qpu_topology = qpu.properties["topology"]["type"]
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
mapped_graph, chain_embedding = fallback
sampler = FixedEmbeddingComposite(qpu, chain_embedding)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this just be put into a helper function and imported into callback_helpers.py?

Comment thread src/utils/common.py
import random
from typing import Callable, Literal, Optional

import dwave_networkx as dnx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better use dwave-graphs here instead, since dnx is deprecated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I have this update locally along with the new implementation of Jacks changes I was just waiting for his PR to be merged so I can test before making a commit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Although maybe it just worth merging these changes and making a followup PR once his PR is merged? Let me know your thoughts

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