Keeping N samples in memory is expensive if we only want the k best ones!
Open question is the interface -- num_reads is synonymous with num_samples returned in sample set for all samplers in Ocean. Also, initial_states (even for random states) are expanded to num_reads input samples -- something we would also want to avoid in this case.
To retain compatible behavior with existing samplers, perhaps we could introduce a parameter like num_resample. Also, resample_reduce_method (min/max). And to support the k best samples use case, we'll need a parameter like num_samples.
So, something like:
ss = greedy.sample(bqm, num_reads=1, num_resample=1000, num_samples=3, resample_reduce_method='k-best')
Another take on this would be async sampler interface. In which case a caller would yield as many samples are needed, all with minimal memory overhead!
Keeping
Nsamples in memory is expensive if we only want thekbest ones!Open question is the interface --
num_readsis synonymous withnum_samplesreturned in sample set for all samplers in Ocean. Also,initial_states(even for random states) are expanded tonum_readsinput samples -- something we would also want to avoid in this case.To retain compatible behavior with existing samplers, perhaps we could introduce a parameter like
num_resample. Also,resample_reduce_method(min/max). And to support thekbest samples use case, we'll need a parameter likenum_samples.So, something like:
Another take on this would be async sampler interface. In which case a caller would yield as many samples are needed, all with minimal memory overhead!