dwave-system
dwave-system copied to clipboard
`LeapHybridCQMSampler` sometimes generates the wrong `time_limit` for problems with sparse objectives
In dimod 0.12.0, the CQM models started storing the variable info globally rather than in the objective. However, the serialization was not changed to match, see https://github.com/dwavesystems/dimod/issues/1303.
This creates a situation where the serialized model does not have the same number of biases as the given model.
Failing example:
import dimod
from dwave.system import LeapHybridCQMSampler
sampler = LeapHybridCQMSampler()
cqm = dimod.ConstrainedQuadraticModel()
cqm.add_variables('INTEGER', 50_000)
cqm.add_constraint([(0, 1, 1)], '==', 0)
print(sampler.min_time_limit(cqm))
new = dimod.ConstrainedQuadraticModel().from_file(cqm.to_file())
print(sampler.min_time_limit(new))
gives
7.87090906404288
8.10376188704288
Proposed Solution
The correct fix is to implement https://github.com/dwavesystems/dimod/issues/1303, though we could as an interim solution read the relevant timing variables off of the header of the serialized model.