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

add LinearAncillaComposite #530

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

pau557
Copy link
Contributor

@pau557 pau557 commented Aug 15, 2024

In scenarios where the h biases are not available or sufficient in range, one can use auxiliary qubits polarized with a large flux bias and coupled to the data qubit. This method:

  • Requires that each qubit is coupled to a non-programmed qubit
  • But, ancilla qubits can be shared between data qubits
  • The magnitude of the bias is limited by the magnitude of the coupler, but in the case of asymetric coupling range, one can use the strongest coupling available and control the bias sign with the flux bias sign

This PR adds a LinearAncillaComposite that implements this technique.

For the reviewers, please take into account future extensions of this method:

  • One can use multiple ancilla qubits to extend the h-range and avoid shrinking energy scales of the problem. This is relevant for QUBO --> Ising translation.
  • While the current implementation may work on embedded problems as is, we need an embedding-aware version that relaxes the condition of each qubit being coupled to an ancilla to each chain being coupled to at least one ancilla.

Please educate me on how to use the correct Sphynx syntax

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 12 lines in your changes missing coverage. Please review.

Project coverage is 86.57%. Comparing base (b233941) to head (5867eba).
Report is 31 commits behind head on master.

Files with missing lines Patch % Lines
dwave/system/composites/linear_ancilla.py 83.09% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #530      +/-   ##
==========================================
- Coverage   89.65%   86.57%   -3.09%     
==========================================
  Files          24       25       +1     
  Lines        1760     1832      +72     
==========================================
+ Hits         1578     1586       +8     
- Misses        182      246      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

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

This can be very useful, @pau557. I made a few comments inline.

Needs to be added to docs here: https://github.com/dwavesystems/dwave-system/blob/master/docs/reference/composites.rst

dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
tests/test_linear_ancilla_composite.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Show resolved Hide resolved
dwave/system/composites/linear_ancilla.py Outdated Show resolved Hide resolved
tests/test_linear_ancilla_composite.py Outdated Show resolved Hide resolved
Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

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

Thank you

docs/reference/composites.rst Outdated Show resolved Hide resolved
docs/reference/composites.rst Outdated Show resolved Hide resolved
@pau557
Copy link
Contributor Author

pau557 commented Nov 19, 2024

Any more comments or ready to merge?

@JoelPasvolsky
Copy link
Contributor

Any more comments or ready to merge?

@pau557 there are comments I think you might have missed, especially ones that use GitHub Suggested Change that have not been added. Examples: 1, 2, 3, 4, 5, etc. Can you look through the comments again?

@pau557
Copy link
Contributor Author

pau557 commented Nov 22, 2024

I had missed many comments, apologies @JoelPasvolsky. I think everything is addressed now

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

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

Just a few small comments.

Comment on lines +89 to +90
This composite does not suport the auto_scale parameter. BQM Scaling
can be done with :class:`~dimod.ScaleComposite`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This composite does not suport the auto_scale parameter. BQM Scaling
can be done with :class:`~dimod.ScaleComposite`.
This composite does not support the :ref:`param_autoscale` parameter; use the
:class:`~dwave.preprocessing.composites.ScaleComposite` for scaling.

can be done with :class:`~dimod.ScaleComposite`.

Args:
bqm (:obj:`~dimod.BinaryQuadraticModel`):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bqm (:obj:`~dimod.BinaryQuadraticModel`):
bqm (:class:`~dimod.binary.BinaryQuadraticModel`):

Args:
child_sampler (:class:`dimod.Sampler`):
A dimod sampler, such as a :class:`~dwave.system.samplers.DWaveSampler()`,
that has flux bias controls.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a small code example, ideally using the EmbeddingComposite or such. See example in TilingComposite for the format and preferred size.

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