dwave-system icon indicating copy to clipboard operation
dwave-system copied to clipboard

Conversion from flux_biases (units of Phi0) to h (unitless) and vice-versa

Open jackraymond opened this issue 11 months ago • 6 comments

Both flux_biases and h apply time dependent longitudinal fields (fields conjugate to sigma^z in the Hamiltonian description, see documentation). At given point in the anneal s=t/t_a, h and flux_biases can apply equal longitudinal fields subject to rescaling. If a freeze-out phenomena is assumed at a given s, as relevant to quantum Boltzmann or Boltzmann sampling, flux_biases can be replaced by h or vice-versa. 'h' is typically unitless, whereas flux has units of Phi0, the conversion is a function of published QPU properties B(s) and M_AFM. This pull request adds code for this conversion.

jackraymond avatar Mar 18 '24 22:03 jackraymond

@JoelPasvolsky suggested as a reviewer.

jackraymond avatar Mar 18 '24 22:03 jackraymond

@jackraymond, I started reviewing now but is it possible you have a switched sign for your temperatures.h_to_fluxbias() function?

>>> fb = [0]*qpu.properties['num_qubits']
>>> fb[30] = temperatures.h_to_fluxbias(0.5)

>>> # What I expect is an equivalent to this (most spins down):

>>> sampleset = qpu.sample_ising({30: 0.5}, {}, num_reads=5000, auto_scale=False)
>>> print(sampleset)
  30 energy num_oc.
0 -1   -0.5    4923
1 +1    0.5      77

 >>> # What I get is the opposite (most spins up):

>>> sampleset = qpu.sample_ising({30: 0}, {}, num_reads=5000, auto_scale=False, flux_biases=fb)
>>> print(sampleset)
  30 energy num_oc.
0 -1    0.0     277
1 +1    0.0    4723

JoelPasvolsky avatar Apr 04 '24 17:04 JoelPasvolsky

@jackraymond, I started reviewing now but is it possible you have a switched sign for your temperatures.h_to_fluxbias() function?

>>> fb = [0]*qpu.properties['num_qubits']
>>> fb[30] = temperatures.h_to_fluxbias(0.5)

>>> # What I expect is an equivalent to this (most spins down):

>>> sampleset = qpu.sample_ising({30: 0.5}, {}, num_reads=5000, auto_scale=False)
>>> print(sampleset)
  30 energy num_oc.
0 -1   -0.5    4923
1 +1    0.5      77

 >>> # What I get is the opposite (most spins up):

>>> sampleset = qpu.sample_ising({30: 0}, {}, num_reads=5000, auto_scale=False, flux_biases=fb)
>>> print(sampleset)
  30 energy num_oc.
0 -1    0.0     277
1 +1    0.0    4723

Yep - convention for flux_biases is opposite to the convention for h. Minus sign matters!

jackraymond avatar Apr 05 '24 16:04 jackraymond

Also need to be added to this file I'm not sure that having these function under Temperature Utilities is optimal.

This repo contains conversions from GHz to kB T , and some other related functions. Not sure there is a better spot. The temperature estimators can use this function directly under the freeze-out hypothesis to estimate effective temperature, so the code will interface directly with other functions in the module.

However, happy to consider other options.

jackraymond avatar Apr 05 '24 16:04 jackraymond

This repo contains conversions from GHz to kB T , and some other related functions.

I wasn't concerned with the source file, I mean that users looking to use flux bias as a substitution for an h bias might not look at this temperature-related doc section. For the docs, should these be bumped out to general Utilities page functions?

JoelPasvolsky avatar Apr 05 '24 16:04 JoelPasvolsky

This repo contains conversions from GHz to kB T , and some other related functions.

I wasn't concerned with the source file, I mean that users looking to use flux bias as a substitution for an h bias might not look at this temperature-related doc section. For the docs, should these be bumped out to general Utilities page functions?

I'll create a 'Unit conversion' subsection, unless you have a better suggestion

jackraymond avatar Apr 05 '24 21:04 jackraymond

@JoelPasvolsky, test failures here are caused by (private) changes in cloud-client 0.11.3. The fix for mock tests that tweak client internals is in https://github.com/dwavesystems/dwave-system/pull/515.

randomir avatar Apr 17 '24 16:04 randomir

Codecov Report

Attention: Patch coverage is 79.31034% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 87.61%. Comparing base (7ddf451) to head (22f3153).

Files Patch % Lines
dwave/system/temperatures.py 79.31% 6 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
- Coverage   90.88%   87.61%   -3.27%     
==========================================
  Files          24       24              
  Lines        1678     1704      +26     
==========================================
- Hits         1525     1493      -32     
- Misses        153      211      +58     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 17 '24 17:04 codecov[bot]