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

Unexpected cutoff behavior for CutOffComposite

Open JoelPasvolsky opened this issue 5 years ago • 15 comments

Description For bqm = dimod.BinaryQuadraticModel({}, {'ab': -0.8, 'ac': -0.7}, 0, dimod.SPIN) I expected that CutOffComposite(AutoEmbeddingComposite(sampler), -.75).sample(bqm, num_reads=1000) would remove interaction ac and found the result puzzling until I saw in the code:

(u, v, bias)
                         for (u, v), bias in original.quadratic.items()
                         if not comp(abs(bias), cutoff))

Either the absolute value for cutoff should be explicitly stated in the parameter description or abs() should be dropped.

I'm in this repo now anyway, if you say what your preferred behavior is, I can implement.

To Reproduce See above.

Expected behavior Stated above

Environment:

  • OS: all
  • Python version: all

Additional context Add any other context about the problem here.

JoelPasvolsky avatar Jul 03 '19 22:07 JoelPasvolsky

not a bug - this is the correct behaviour. The cutoffcomposite is implemented for precision errors.

conta877 avatar Jul 03 '19 22:07 conta877

@conta877, this issue isn't saying that there is a bug in the implementation. I found the behavior unexpected based on the description of parameter cutoff. If I have interactions -0.7 and -0.9 and I specify cutoff=-0.8 then I would expect, based on the description "The lower bound for interaction bias magnitudes", that it would drop -0.7. That is not the case. Above I suggest "Either the absolute value for cutoff should be explicitly stated", which I think would clarify the description if this is the desired behavior. No?

JoelPasvolsky avatar Jul 03 '19 23:07 JoelPasvolsky

the fact that this was an unexpected behaviour for you tells me that I did a bad job describing what the composite does. So yes changing the parameter definition to explicitly say absolute + better description may be necessary

conta877 avatar Jul 03 '19 23:07 conta877

Agree the documentation should be updated to make it explicit that the cutoff is around 0.

arcondello avatar Jul 04 '19 00:07 arcondello

I suppose we could update the composite to allow the user to specify a range (treating a single number as a symmetric range) e.g.

CutOffComposite(AutoEmbeddingComposite(sampler), .75)

would be the same as

CutOffComposite(AutoEmbeddingComposite(sampler), (-.75, .75))

but the user could instead

CutOffComposite(AutoEmbeddingComposite(sampler), (-.75, 0))

That said, I cannot really imagine a use-case that needs that much flexibility.

arcondello avatar Jul 04 '19 15:07 arcondello

I am against that idea. the main reason for this composite is precision issues.

conta877 avatar Jul 04 '19 15:07 conta877

Who are we to tell people what to use it for? :smile: But yeah, need a use-case to justify the implementation time.

arcondello avatar Jul 04 '19 15:07 arcondello

@conta877: image

JoelPasvolsky avatar Jul 04 '19 17:07 JoelPasvolsky

how about "interactions with precision below a specified cutoff value"

conta877 avatar Jul 04 '19 18:07 conta877

If I understand your intent correctly, you want to convey that the practical use of this composite relates to the limits of precision in programming qubit biases. I'm not sure that comes across from that proposal because we tend to think of precision as a delta on any value and here the cutoff is around zero. What about separate statements: (1) explains the practical use and talks about precision and (2) defines what interactions are cut off?

JoelPasvolsky avatar Jul 04 '19 18:07 JoelPasvolsky

@JoelPasvolsky I trust your judgement more than my own on this!

conta877 avatar Jul 04 '19 18:07 conta877

Okay, I'll try propose something that won't badly disappoint your misplaced trust

JoelPasvolsky avatar Jul 04 '19 18:07 JoelPasvolsky

Back working on this part again. @conta877, please let me know if this isn't your intended use for this composite re precision:

class CutOffComposite(dimod.ComposedSampler):
    """Composite to remove interactions below a specified cutoff value.

    Downsizes the binary quadratic model (BQM) submitted to the child sampler by retaining 
    only interactions with values commensurate with the sampler's precision. Also removes 
    variables isolated post...

JoelPasvolsky avatar Jul 04 '19 21:07 JoelPasvolsky

so now this sounds like we actually provide a precision for samplers.

How about "commensurate with a precision given by cutoff" ?
or "bounded by -cutoff < val < cutoff"

conta877 avatar Jul 04 '19 22:07 conta877

I think that once we introduce the notion of precision, it needs to be related to some quantity, which I understand to be the actual programmed values of the biases of qubits & couplers on the QPU versus desired variable values, otherwise we're leaving users unclear on what is the problem the composite is meant to overcome. The cutoff parameter sets a number on it but doesn't relate it to its object.

For your point that it "sounds like we actually provide a precision for samplers":

  • If by "we" you mean the CutOffComposite, I would not expect the second sentence to be misinterpreted in that was coming after a first sentence that states "below a specified cutoff value" but how about changing to the more explicit "interactions with values commensurate with the sampler's specified precision" or even more explicit "interactions with values commensurate with the sampler's precision as specified by the cutoff argument"?

  • If by "we" you mean D-Wave for its systems, we can add a reference to the system documentation's Technical Description of the QPU

JoelPasvolsky avatar Jul 05 '19 12:07 JoelPasvolsky