Skip to content
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

Deprecate VirtualGraphComposite #532

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion dwave/system/composites/virtual_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
# limitations under the License.

"""
Deprecated.
Virtual graphs are deprecated due to improved calibration of newer QPUs; to
calibrate chains for residual biases, follow the instructions in the
`shimming tutorial <https://github.com/dwavesystems/shimming-tutorial>`_.

Comment on lines +16 to +20
Copy link
Member

Choose a reason for hiding this comment

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

Consider using .. deprecated:: version Sphinx directive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that now for the class (line 50 below).

A :std:doc:`dimod composite <oceandocs:docs_dimod/reference/samplers>` that
uses the D-Wave virtual graph feature for improved
:std:doc:`minor-embedding <oceandocs:docs_system/intro>`.
Expand All @@ -32,14 +37,19 @@
from dwave.system.composites.embedding import FixedEmbeddingComposite
from dwave.system.flux_bias_offsets import get_flux_biases

from warnings import warn
Copy link
Member

Choose a reason for hiding this comment

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

Python libraries get imported first.

Also, IMO it's nicer to just import warnings then do warnings.warn for a slightly cleaner namespace.


FLUX_BIAS_KWARG = 'flux_biases'

__all__ = ['VirtualGraphComposite']


class VirtualGraphComposite(FixedEmbeddingComposite):
"""Composite to use the D-Wave virtual graph feature for minor-embedding.
"""Deprecated. Composite to use the D-Wave virtual graph feature for minor-embedding.

This class is deprecated due to improved calibration of newer QPUs; to
calibrate chains for residual biases, follow the instructions in the
`shimming tutorial <https://github.com/dwavesystems/shimming-tutorial>`_.

Calibrates qubits in chains to compensate for the effects of biases and enables easy
creation, optimization, use, and reuse of an embedding for a given working graph.
Expand Down Expand Up @@ -127,6 +137,13 @@ def __init__(self, sampler, embedding,
flux_bias_max_age=3600):

super(VirtualGraphComposite, self).__init__(sampler, embedding)
warn(
"'VirtualGraphComposite' is deprecated due to improved calibration "
"of newer QPUs and in future will raise an exception; if needed, "
"follow the instructions in the shimming tutorial at "
"https://github.com/dwavesystems/shimming-tutorial instead. ",
DeprecationWarning
Copy link
Member

Choose a reason for hiding this comment

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

I think we might need to set the stacklevel for the warning to be shown from the correct code line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that we are inconsistent. LeapHybridDQMSampler sets the stacklevel but LazyEmbeddingComposite does not. I think we need that to override Python's newer default that doesn't show warnings unless users set them to show. Do we want to do that?

)
self.parameters.update(apply_flux_bias_offsets=[])

# Validate the chain strength, or obtain it from J-range if chain strength is not provided.
Expand Down