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())

qpu.sample_ising(..., num_spin_reversal_transforms=10, ...) 
 
I understand that this class will automatically apply the spin-reversal transform to the h and J values as well as the returned solution. I assume then that SpinReversalTransformComposite only applies the transform to J values within the symmetric range ([-1,+1]). Is that right?
 
When I tried using SpinReversalTransformComposite the returned sampleset did not contain any timing info and the lowest energy solution was well below the actual optimal value.
 
Best wishes,
Michael
 
 
0

Comments

8 comments
  • Apologies, end of last sentence should read "...was well above the true minimum energy."

    0
    Comment actions Permalink
  • 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:

    sampler = EmbeddingComposite(SpinReversalTransformComposite(DWaveSampler()))
    sampler = SpinReversalTransformComposite(EmbeddingComposite(DWaveSampler()))

    Thank you for your patience while I confirm all of the above. Hopefully the code references help you in the mean time.

    0
    Comment actions Permalink
  • Thanks David,

    Submitting the logical qubits with SpinReversalTransformComposite does appear to work in that it does return the optimum solution.

    sampleset = FixedEmbeddingComposite(SpinReversalTransformComposite(qpu), embedding).sample_ising(
    logical_h, logical_J,
    num_reads=n_reads, annealing_time=ta, auto_scale=True,
    num_spin_reversal_transforms=n_gauges
    )
    And looking at the D-Wave Leap Dashboard, I can find the Problem Parameters for the job. The data field appears to show the result of applying a gauge transform to the unscaled physical parameters. Further, this data features extra couplings that do not appear in the physical J values obtained as shown below.
    physical_h, physical_J = dwave.embedding.embed_ising(logical_h, logical_J, embedding, qpu.adjacency)
    I'm somewhat confused as to where these extra couplings are coming from.

    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.
    0
    Comment actions Permalink
  • 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.

    1. Flipping a qubit necessitates flipping connected couplers
    2. The SpinReversalTransformComposite can flip Logical or Physical qubits as follows:
      sampler = SpinReversalTransformComposite(EmbeddingComposite(DWaveSampler()))
      sampler = EmbeddingComposite(SpinReversalTransformComposite(DWaveSampler()))
    3. In general the SpinReversalTransformComposite doesn't avoid extended ranges.
      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.
    4. Qubits in chains generally avoid using extended h and J ranges except in a few cases such as VirtualGraphComposite where extended J ranges are used by default (see code).

    Are you able to give a minimal example of the extra couplings you're seeing? What are they connected to?

    0
    Comment actions Permalink
  • A quick question on point 2 of your previous post. Is it the second sampler assignment that would be used if flipping logical qubits?

    sampler = EmbeddingComposite(SpinReversalTransformComposite(DWaveSampler()))
    0
    Comment actions Permalink
  • 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.

    sampleset = SpinReversalTransformComposite(FixedEmbeddingComposite(qpu, embedding)).sample_ising(
    physical_h, physical_J,
    num_reads=n_reads, annealing_time=ta, auto_scale=True,
    num_spin_reversal_transforms=n_gauges
    )

    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.

    minorminer.utils.exceptions.MissingChainError: chain for 994 is empty or not contained in this embedding

    It's as if the code is still expecting logical qubits.

    0
    Comment actions Permalink
  • 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.

    physical_h, physical_J = dwave.embedding.embed_ising(logical_h, logical_0, embedding, qpu.adjacency)

    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.

    0
    Comment actions Permalink
  • Hello,

    For doing SRT:

    # On Logical qubits with EmbeddingComposite:
    sampler = SpinReversalTransformComposite(EmbeddingComposite(DWaveSampler()))

    # On Logical qubits with FixedEmbeddingComposite:

    qpu = DWaveSampler()
    sampler = SpinReversalTransformComposite(FixedEmbeddingComposite(qpu, embedding))

    And:

    # On Physical qubits with EmbeddingComposite:
    sampler = EmbeddingComposite(SpinReversalTransformComposite(DWaveSampler()))

    # On Physical qubits with FixedEmbeddingComposite:

    qpu = SpinReversalTransformComposite(DWaveSampler())
    sampler = FixedEmbeddingComposite(qpu, embedding)


    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.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post