Spin-Reversal (Gauge) Transforms
I've been trying to apply a technique know as partial gauge transform to an embedded and pre-scaled Ising formulation, i.e., the h and J dictionaries have physical qubit numbers as keys and the values have been scaled so as to fit the h and J ranges defined for the Advantage System 6.4 QPU.
This technique is explained in a paper entitled, Ferromagnetically Shifting the Power of Pausing.
Basically, each physical qubit bias is multiplied by a coefficient, randomly chosen to be either -1 or +1. The coupling strengths are similarly transformed by the pairs of coefficients associated with the coupled qubits. However, the coupling strength is not transformed if it is in the J extended range, -2 to -1, such as is the case for chained qubits. In other words, the transform is only applied to coupling strengths that lie within the symmetric J range, -1 to 1.
Unfortunately, my implementation of the above results in a returned "sampleset.first.sample" containing numerous broken chains. The gauge coefficients are multiplied by the final physical qubit values before an attempt is made to recover the logical qubit values. If I remove the gauge transforms the code works as expected.
Can you think of a reason why partial gauge transforms would not work on D-Wave annealers?
Alternatively, is it possible to do such transforms using the SpinReversalTransformComposite class provided by the Ocean SDK?
qpu = SpinReversalTransformComposite(DWaveSampler())
Comments
Apologies, end of last sentence should read "...was well above the true minimum energy."
Hello,
Thank you for your patience.
The implementation of the SpinReversalTransformComposite can be found here:
https://github.com/dwavesystems/dwave-preprocessing/blob/0.6.7/dwave/preprocessing/composites/spin_reversal_transform.py
The SpinReversalTransformComposite flips the value of the BQM qubit here:
https://github.com/dwavesystems/dwave-preprocessing/blob/0.6.7/dwave/preprocessing/composites/spin_reversal_transform.py#L198
The implementation of the qubit flipping function can be found here:
https://github.com/dwavesystems/dimod/blob/0.12.18/dimod/binary/binary_quadratic_model.py#L1306
Note that for every qubit that is flipped, all connected couplers are also flipped. This assures the problems are equivalent to one another. Did you happen to do this in your implementation?
Qubits in chains need to all share the same linear and quadratic scalars, so it seems unlikely that extended ranges would be used, since they would be limited by the range of the smallest qubit or coupler in the chain. That said, I will confirm.
Extended h and J ranges offer some added benefits but also have many limitations. In cases where the problem naturally limits ranges, such as chains and SRTs, it is less likely that scalars would be set to values outside of the normal range [-1, 1]. All extended range qubits and couplers can operate within the normal range too, so it is unlikely that flipping them is avoided, so much as that the extended range is not used.
If I understand correctly, depending at what level the SpinReversalTransformComposite is placed, it can flip physical or logical qubits:
Thank you for your patience while I confirm all of the above. Hopefully the code references help you in the mean time.
Thanks David,
Submitting the logical qubits with SpinReversalTransformComposite does appear to work in that it does return the optimum solution.
Otherwise, the data accessible via the dashboard indicates that a coupling strength is flipped if one and only one of the coupled qubits has had its bias flipped. This also applies to couplings between chained qubits, for which the scaled coupling strength would lie in the extended J range, -2 to -1.
No problem!
I heard back from the team and was able to confirm some information from my last post and also gather a little more.
sampler = SpinReversalTransformComposite(EmbeddingComposite(DWaveSampler()))
sampler = EmbeddingComposite(SpinReversalTransformComposite(DWaveSampler()))
Using autoscale=True (default) brings problems into range, while autoscale=False does not.
Extended J ranges can be used in chains where SRT is on Logical qubits.
Are you able to give a minimal example of the extra couplings you're seeing? What are they connected to?
A quick question on point 2 of your previous post. Is it the second sampler assignment that would be used if flipping logical qubits?
Flipping logical qubits using the form posted above works for me, but trying the other form (listed first in your post) for physical qubits does not.
A slight difference here is that I'm using FixedEmbeddingComposite in order to pass an embedding determined previously via "minorminer.find_embedding(...)".
The error message generated when trying to flip physical qubits is shown below.
It's as if the code is still expecting logical qubits.
Re the extra couplings, I have a zip file that contains the relevant info.
1. logical-h.txt: the logical qubit biases
2. logical-J.txt: the logical qubit coupling strengths
3. embedding.txt: the embedding mapping logical qubits to physical qubits
4. physical-h.txt: the physical qubit biases
5. physical-J.txt: the physical qubit coupling strengths
6. dwave-dashboard-h.txt: the physical qubits biases returned by QPU (Advantage7.1) job
7. dwave-dashboard-J.txt: the physical qubit coupling strengths returned by QPU (Advantage7.1) job
8. dwave-dashboard-inferred-gauge.txt: the gauge values (one per physical qubit) inferred from comparing "physical-h.txt" with "dwave-dashboard-h.txt".
The contents of files 4 and 5 were obtained by running the code shown below.
The contents of files 6 and 7 was returned by D-Wave Job ID 83eed37b-05e4-4dc0-afd1-bd480913093f.
Although the qubit biases (files 4 and 6) are consistent, the qubit couplings are not (files 5 and 7).
The "dwave-dashboard-J.txt" file contains 23 couplings not found in "physical-J.txt", however, all of these have been assigned a coupling strength of zero - would these have any significance?
By the way, what's the best way to send you the zip file?
I can't find a way to attach it to this post.
Hello,
For doing SRT:
And:
Generally, to provide code examples and samplesets, we request that you create a minimal code example that demonstrates the behaviour in as few lines of code as possible that will produce the expected output or behaviour.
This code example would then be posted to the Community, or by including the code example and a link to the community post in the body of an email to support@dwavesys.com (not an attachment).
I will also try to reproduce this behaviour, but I am assuming that because the coupling strengths are zero that these might be an artifact of flipping all adjacent couplers. A coupler strength of zero would imply no interaction, but in general it's a good idea to just not include those qubits and couplers.
Please sign in to leave a comment.