Different output frequency despite same energy?
This is the output I got from running a program on the quantum annealer:
{'z': 1, 'a': 0, 'x1': 1, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 174
{'z': 0, 'a': 1, 'x1': 0, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 6
How is it possible that the first binary configuration is occurring much more than the second, despite them both having the same energy?
Comments
Hi,
this is interesting. Could you let me know the equation for calculating the energy from the binary configuration? There are several reasons which may cause this unbalanced answers within a degenerate ground space.
Hi Edward, thank you for your response.
For sure, here is the code I’m running:
from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite
sampler = EmbeddingComposite(DWaveSampler(endpoint='', token='', solver=''))
query3 = {('x1', 'x2'): 2, ('x1', 'z'): -2, ('x2', 'z'): -2, ('z', 'z'): 2, ('z', 'a'): 2, ('a', 'a'): -1, ('x1', 'x1'):1, ('x2', 'x2'):1, ('x2', 'd'):-2, ('x1', 'd'):-2, ('d', 'd'):1}
response = sampler.sample_qubo(query3, num_reads=200)
for datum in response.data(['sample', 'energy', 'num_occurrences']):
print(datum.sample, "Energy: ", datum.energy, "Occurrences: ", datum.num_occurrences)
And here is the full set of outputs (I didn’t include all of them in my question). In addition to the problem posed in the question, as can be seen, for some reason, one of the outputs repeats twice (first and third outputs have the same values for each of the parameters):
{'z': 1, 'a': 0, 'x1': 1, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 173
{'z': 0, 'a': 1, 'x1': 0, 'x2': 0, 'd': 0} Energy: -1.0 Occurrences: 14
{'z': 1, 'a': 0, 'x1': 1, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 1
{'z': 0, 'a': 1, 'x1': 1, 'x2': 0, 'd': 1} Energy: -1.0 Occurrences: 6
{'z': 0, 'a': 1, 'x1': 0, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 6
Hi Jack,
So there are a couple of things happening here.
In regards to the duplicate values, this happens due to chain breaks.
There is a great explanation in this community post:
https://support.dwavesys.com/hc/en-us/community/posts/360014600213
Chain breaks are when the the qubits in a chain take different values.
Chains are sets of qubits that act as a single qubit.
Here is a brief introduction to chains:
https://support.dwavesys.com/hc/en-us/community/posts/360016697094
Chains are the result of a problem being embedded into the Chimera graph shape of the QPU, in a process called minor embedding.
Minor embedding is used to adapt an arbitrary graph into a Chimera graph.
Here is a link to documentation about minor embedding:
https://docs.dwavesys.com/docs/latest/c_gs_4.html
EmbeddingComposite uses minor embedding to pass the query to the DWaveSampler.
The next thing happening is also due to chain breaks.
When the problem is unembedded, the chain breaks are resolved.
In this case there was one configuration (the one with 173 occurrences), which had a broken chain with a lower energy than the unbroken chain results.
This meant that this particular result was much more favourable, resulting in the large number of occurrences.
{1526: 0, 1528: 1, 1530: 1, 1532: 1, 1534: 1, 1535: 0} Energy: -1.5 Occurrences: 164
{1526: 1, 1528: 1, 1530: 0, 1532: 1, 1534: 0, 1535: 1} Energy: -1.0 Occurrences: 6
{1526: 1, 1528: 0, 1530: 1, 1532: 1, 1534: 0, 1535: 0} Energy: -1.0 Occurrences: 10
{1526: 0, 1528: 1, 1530: 1, 1532: 1, 1534: 1, 1535: 1} Energy: -1.0 Occurrences: 4
{1526: 1, 1528: 0, 1530: 0, 1532: 0, 1534: 0, 1535: 0} Energy: -1.0 Occurrences: 16
The resolve step put it into a valid state, but also changed the energy to be equal to the energies of the other lowest energy results (including the duplicate).
{'z': 1, 'a': 0, 'x1': 1, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 164
{'z': 0, 'a': 1, 'x1': 1, 'x2': 0, 'd': 1} Energy: -1.0 Occurrences: 6
{'z': 0, 'a': 1, 'x1': 0, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 10
{'z': 1, 'a': 0, 'x1': 1, 'x2': 1, 'd': 1} Energy: -1.0 Occurrences: 4
{'z': 0, 'a': 1, 'x1': 0, 'x2': 0, 'd': 0} Energy: -1.0 Occurrences: 16
The embedding for this configuration was:
{'x1': [1528, 1535], 'x2': [1530], 'z': [1534], 'a': [1526], 'd': [1532]}
We can see that logical qubit x1 maps to physical qubits 1528 and 1535.
These two physical qubits take different values, but looking at the resolved version, x1 is equal to 1.
The first linked community post above (https://support.dwavesys.com/hc/en-us/community/posts/360014600213) explains in better detail what the actual process is in deciding the resolved logical qubit values.
So, to fix this, we want to increase the chain strength.
By default the chain strength is 1.0.
As a general rule of thumb we want the chain strength to be in the order of magnitude of the largest bias, in this case 2.0, or higher in some cases.
I was able to obtain much more evenly distributed results by adding the chain strength to your code example as in the following:
Hi David - This is fantastic, thank you so much for your help!
Please sign in to leave a comment.