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

Make TilingComposite tile-aware

Open jberwald opened this issue 5 years ago • 4 comments

Current Problem TilingComposite currently treats a tiling of the QPU as a single entity. Based on a too-literally reading of the definition of a tiling (fixed geometric shapes or tiles filling space) I thought one could take a single, small tile, represented by a BQM, tile the QPU with that shape, and run many copies of that BQM. While this is possible using the child sampler, it is not intuitive.

Here's a sample problem: The tiling produced by TilingComposite(DWaveSampler(), 2,2,4) is composed of a bunch 32-qubit tiles. The figure below is a representation where each tile is an 32-qubit RAN-1 problem. download-1 The blank spots are where bum qubits won't allow a perfect tile.

Proposed Solution Make TilingComposite tile-aware. Let tiles = [bqm for a single tile] and define fullBQM = dimod.BQM(linear={all linear terms from tiles}, quadratic={all coupling in tiles}. Something like TilingComposte.sample_tiling(fullBQM) should return a SampleSet. Currently TilingComposte.sample(fullBQM) throws an error: BinaryQuadraticModelStructureError: given bqm does not match the sampler's structure.

jberwald avatar Jul 05 '19 16:07 jberwald

How about

sampler = DWaveSampler()
tiles = find_tiles(sampler.structure, 2, 2, 4)
bqm = dimod.BQM.empty('SPIN')
for tile in tiles:
    bqm.update(dimod.ran_r(1, tile))
sampleset = sampler.sample(bqm)

if we exposed the find_tiles function used by the TilingComposite?

It is worth noting that the original feature request for the TilingComposite was for something like

bqms = [dimod.ran_r(1, dnx.chimera_graph(2, 2, 4)) for _ in range(5)]  # get 5 different C2 BQMs
sampleset = TilingComposite(DWaveSampler()).sample(bqms)

the problem is that the Sampler API does not support accepting multiple BQMs.

arcondello avatar Jul 05 '19 16:07 arcondello

Your first code block basically lays out what I'm doing already (with more code, of course). So yes, that seems like a nice solution.

jberwald avatar Jul 05 '19 16:07 jberwald

As a side note, it seems like the TilingComposite excludes a fair amount of real estate in the example above. Am I understanding it's tiling procedure correctly in relation to inactive qubits and why some regions are not tiled?

jberwald avatar Jul 05 '19 17:07 jberwald

Yes, though it finds the regions in a pretty naive/greedy way so it can miss a lot of realestate.

arcondello avatar Jul 05 '19 18:07 arcondello