Closed bqth29 closed 2 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
6194a9e
) to head (9ff455d
). Report is 6 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Overriden by #78
π¬ Pull Request Description
Based on #41, a reflexion was carried out regarding the difference between the models' dtype and the computation dtype.
Because the oscillators in the SB backend are in [-1, 1], the backend computation dtype must be a float. Besides, some key PyTorch methods are not available for
float16
so onlyfloat32
andfloat64
are considered.Thus, the core Ising model which is used by the SB optimizer can only be defined with
float32
(default) orfloat64
dtype, any other dtype will raise aValueError
.However,
QuadraticPolynomial
s can still be of any dtype. When such a polynomial is converted to an Ising model, a newdtype
argument must be passed to indicate the dtype of the Ising model that will be generated. When callingQuadraticPolynomial::optimize
,QuadraticPolynomial::maximize
orQuadraticPolynomial::minimize
, adtype
argument must also be provided to indicate the backend dtype (for equivalent Ising model and thus SB optimizer computations).Once the optimal spins are retrieved by the polynomial at the end of the optimization and converted to integer values according to the optimization domain, the tensors are converted to the polynomial's dtype.
When passing the
dtype
parameter to thesb.maximize
/sb.minimize
functions, the dtype will be used as theQuadraticPolynomial
's dtype and as the optimization dtype. If not provided,float32
will be used.Finally, for
Polynomial
s, if thedtype
and/ordevice
parameters are set to None, the default dtype and/or device of PyTorch will be used.βοΈ Check list
π New features
None.
π Bug fixes
None.
π£ Supplementary information
None.