# DWaveSampler with large matrix

The SimulatedAnnealingSampler works quickly for a small (5x5) or a large (812x812) QUBO matrix. However, the DWaveSampler is working quickly for only the small matrix and not completing for the large matrix - and after a long time the error ValueError("no embedding found") is returned. See option 1 and 2 in the code below for the two samplers. May I ask if this is coded up correctly?

Q = [imported matrix]

bqm = dimod.BinaryQuadraticModel.from_numpy_matrix(Q, variable_order=None, offset=0.0, interactions=None)

# option 1

sampler = EmbeddingComposite(DWaveSampler())

# option 2

sampler = neal.SimulatedAnnealingSampler()

sampleset = sampler.sample(bqm, chain_strength=1000, num_reads = 10)

print(sampleset)

## Comments

David J(Report)Hello,

The short answer to your question is that Simulated Annealing functions differently to the Quantum Annealer.

The dwave-neal library offers a Simulated Annealing Sampler which uses the simulated annealing algorithm to find good solutions to hard problems.

The Quantum Annealer takes advantage of our system to sample your problem with real hardware.

That said, like all hardware, it has its physical limitations on the size of problem that can be represented and sampled on it.

The Quantum Annealers are not fully connected graphs. Their Qubits are only connected to a number of neighbours.

To get around this and embed more dense problems, we use a technique called "minor embedding" where some qubits act as a "chain" representing a single qubit.

https://docs.ocean.dwavesys.com/en/stable/concepts/embedding.html

For the 2000Q chip a fully connected graph of 65 logical variables can be embedded.

https://support.dwavesys.com/hc/en-us/community/posts/360034818174

For the Advantage chip a fully connected graph of 100 logical variables can be embedded.

https://support.dwavesys.com/hc/en-us/articles/360056412653

The equivalent for a fully connect graph of N qubits would be a square matrix with all non-zero values of dimensions N x N, i.e. 65 x 65 matrix is equivalent to 65 fully connected nodes; 100 x 100 matrix is equivalent to 100 fully connected nodes.

If there are a lot of zeros - a sparse matrix - larger problems of more variables can also be solved using the Quantum Annealer.

If you would like to run large problems like the 812 x 812 matrix with a higher number of off-diagonal terms, you could take advantage of the Hybrid Solver Service, which uses a combination of classical and quantum computing to solve problems.

The LeapHybridSampler uses the Quantum Annealer under the hood.

https://docs.dwavesys.com/docs/latest/doc_leap_hybrid.html

Also check out this link as well.

https://support.dwavesys.com/hc/en-us/articles/360057382393

I hope this is helpful!

Please let us know if you have more questions.

Please sign in to leave a comment.