How to retrieve rescaled h and J values after auto_scale on D-Wave QPU?

Hi,

I'm working on a problem that I solve using a D-Wave QPU, and I have a question regarding auto-scaling of the problem's h (linear coefficients) and J (quadratic coefficients) values.

According to the documentation, if the auto_scale parameter is enabled (which it is by default), the h and J values of the problem are rescaled to fit the QPU's h_range and extended_j_range. I would like to retrieve the rescaled h and J values but have not been able to find a way to accomplish this.

Here is a small example code which I would like to extend to be able to retrieve the rescaled values:

import dimod
import dwave.inspector
from dwave.system import DWaveSampler, EmbeddingComposite

# define problem
bqm = dimod.BQM.from_ising({'a': 0.1, 'b': 0.2, 'c': 0.3}, {'ab': 0.4, 'bc': 0.5, 'ca': 0.6})
# get sampler
sampler = EmbeddingComposite(DWaveSampler())
# sample
sampleset = sampler.sample(bqm, num_reads=100)

One thought that came to my mind was that I might be able to see the rescaled values in the embedded problem using the Problem Inspector:

dwave.inspector.show(bqm, sampleset)

However, it only shows the h and J values that I originally defined, not the rescaled ones. I find this quite strange, as the embedded problem on the Target - QPU should reflect the actual values of the physical problem.

Despite these attempts, I haven't been able to retrieve the actual post-scaling h and J values that are used on the physical qubits.

In summary, I have two questions:

  • I would like to find a way to retrieve the actual rescaled h and J values that are used on the physical qubits.
  • Is there an explanation as to why the Problem Inspector on the Target - QPU only shows the unscaled values, rather than the rescaled ones?

Any help would be greatly appreciated!

Thanks in advance!

0

Comments

1 comment
  • Hello,

    There currently exists a feature request to include the scalar used for auto-scaling in the SampleSet returned by the SAPI endpoint.

    For the time being, running the following code will calculate the default scalar value for a given BQM:

    import numpy as np
    from dwave.preprocessing import ScaleComposite
    from dimod import TrackingComposite
    sampler=TrackingComposite(ScaleComposite(RandomSampler()))
    bqm = dimod.BQM(np.random.randn(20, 20), dimod.BINARY)
    sampleset=sampler.sample(bqm)
    scalar = sampleset.info["scalar"]
    # Print out the default scalar value calculated for the provided BQM
    print(sampleset.info["scalar"])
    # Print out the provided BQM
    print(bqm)
    # Print out the scaled BQM
    print(scalar*bqm)

    Hopefully this was helpful.
    Please let us know if you have any questions.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post