How to use uniform_torque_compensation

Hello!

I am trying to tune some parameters of my model and was curious how to use uniform_torque_compensation described here: [https://docs.ocean.dwavesys.com/projects/system/en/latest/reference/generated/dwave.embedding.chain_strength.uniform_torque_compensation.html].

So, I got a feeling that this feature supposed to give an approximate value for the chain strength. However, it does not seem to work. For example, I figured our that the working value of chain strength for my model is around 200, while  uniform_torque_compensation gives around 1000.

Any suggestions how it works? Do I use it incorrect?

Thanks.

0

Comments

6 comments
  • Hello,

    How are you using the function at present? 
    Could you possibly provide a small code example?

    The uniform_torque_compensation function is used by the EmbeddingComposite by default. 

    For example, the following code uses uniform_torque_compensation underlyingly:

    from dwave.system.samplers import DWaveSampler
    from dwave.system.composites import EmbeddingComposite

    sampler = EmbeddingComposite(DWaveSampler())
    sampleset = sampler.sample(bqm)
    0
    Comment actions Permalink
  • Hi David!

    I just output results of it function to see what values it produces.

    I use FixEmbeddingComposite.

    I hope this function could give some hint on how to set up chain_strength with each increment in the problem's size.

    Best,

    Olga

    0
    Comment actions Permalink
  • Hello, 

    This should be the same for the FixedEmbeddingComposite:
    https://docs.ocean.dwavesys.com/projects/system/en/latest/_modules/dwave/system/composites/embedding.html#FixedEmbeddingComposite

    In the source code in the documentation, you can see that the function is called using a reference to the bqm and the EmbeddedStructure:

    if chain_strength is None: 
    chain_strength = uniform_torque_compensation

    if
    callable(chain_strength):
      chain_strength = chain_strength(source_bqm, self)

    How are you calling the function? Are you providing the bqm only or are you providing the embedding parameter as well with the uniform_torque_compensation function?

    Are you setting the chain_strength manually for your FixedEmbeddingComposite or letting it find it automatically? 

    How are you comparing results from the examples you mentioned earlier?

    If you are able to provide a minimal code example showing precisely how you are calling functions and the outputs you are getting it might help in better pinpointing the behaviour you are seeing. 

     

    0
    Comment actions Permalink
  • Hi David!

    I am submitting the DWaveSampler and BQM with the uniform_torque_compensation function.

    In my case I am passing the chain_strength with sampler.

    Main main concern was that a low value of chain_strength violated the constraint part of the BQM. Only after I figured out sufficient chain_strength, I got better solutions. So, when I rely on embedding part only, the constraints were violated.

    Again, is there any correlation of the uniform_torque_compensation function with chain_strength to help at narrowing down chain_strength parameter in general?

    solver = DWaveSampler()
    print(uniform_torque_compensation(bqm, solver))
    #load embedding
    with open('qpu_embeddings.json') as file:
    data = file.read()

    embedding = json.loads(data)

    sampler = FixedEmbeddingComposite(solver, embedding)
    sampleset = sampler.sample(bqm, num_reads=num_reads, chain_strength=chain_strength)
    0
    Comment actions Permalink
  • Hi David!

    I looked over docs one more time. So, do I understand the following correctly. I can either pass chain_strength with sampler or as one of the embedding_parameters with EmbeddingComposite()?

    If I don't pass chain_strength at all, it will try to approximate it with uniform_torque_compensation ?

     

    Thanks.

    0
    Comment actions Permalink
  • Hello,

    The chain_strength is passed with the sample call itself, as described in the docs here:
    https://docs.dwavesys.com/docs/latest/c_gs_9.html?highlight=chain_strength

    If the chain_strength is not explicitly provided, uniform_torque_compensation should be used.

    Possibly the results will not be as good as a hand-picked value for chain strength. The uniform_torque_compensation function just attempts to select an appropriate chain strength.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post