How to get number of qubits from FixedEmbeddingComposite?
I'd like to get the number of qubits from FixedEmbeddingComposite, but I'm not able to do so the way I am with other embeddings:
# Create a random problem with a complete graph >>> bqm = dimod.generators.uniform(20, "BINARY") ... >>> # Select a QPU, find an embedding for the problem and the number of required qubits >>> qpu = DWaveSampler() >>> embedding = find_clique_embedding(bqm.variables, qpu.to_networkx_graph()) >>> num_qubits = sum(len(chain) for chain in embedding.values())
However, when I try setting `embedding=FixedEmbeddingComposite` in the above code block, the code errors. How do I get the number of qubits from `FixedEmbeddingComposite`?
Comments
Hello,
The FixedEmbeddingComposite is used to apply an embedding to the logical qubits of a problem to map them to the physical qubits of a QPU.
It takes an embedding as one of its parameters.
To use it, you need to find an embedding as you've done above, and provide it to the FixedEmbeddingComposite.
The benefit is that you can reuse the same embedding in multiple calls, unlike the EmbeddingComposite. This means that you can save an embedding to reuse later, saving on time and compute power.
I hope this was helpful.
Please let us know if you have any questions.
Thanks, that helps. I ran your code and I see how it provides a valid embedding. But I'm at a loss for how to choose an embedding for my own problems. My problems are similar to scheduling problems.
I've read all of your responses on this thread: https://support.dwavesys.com/hc/en-us/community/posts/360031592014-Troubleshooting-poor-results
And in your responses you are implying that using the Chimera graph is the best method available. I've tried several things:
1) Using the default embedding: `sampler = EmbeddingComposite(DWaveSampler())`. It seemsto work for small-sized problems ~ 80 variables. But even with about 400 variables, I'm getting "ValueError: no embedding found".
2). I tried using these three: pegasus.find_clique_embedding, chimera.find_clique_embedding, chimera.find_biclique_embedding. And when I try these I get a very cryptic error:
TypeError: unsupported operand type(s) for -: 'Graph' and 'int'
Are 1) and 2) both the expected behavior for problems of my size? I know finding an embedding can be tricky, but I wonder if I'm missing some obvious way to do this. I'd imagine problems larger than 80 variables can be solved using a different embedding.
I also thought I might mention : The problems with 80 variables, don't return *feasible* solutions, even after inserting a pause in the annealing schedule (as you suggested in the linked post), and taking 2000 reads. I just want to check - is this the expected behavior for problems of this size?
Hello,
Thank you for taking the time to read through our other posts and reach out to us with your inquiry.
Chimera is one of our older architectures and is no longer in production. Luckily our Pegasus and Zephyr topologies have more qubits and couplers than our Chimera topology did, and are both compatible with embeddings on the Chimera topology:
https://docs.dwavesys.com/docs/latest/c_gs_4.html
Understanding the embedding process is important if you would like to use the QPU directly. Since the QPU is a fixed size, minor embedding becomes increasingly difficult and then impossible as the problem increases in size. The error, "ValueError: no embedding found", is indicating either that the problem is too big for the QPU, or close to the maximum size so embeddings are hard to find. If you haven't had a chance to look at the documentation for Minor Embedding you might find it useful. Please take a look here:
https://docs.dwavesys.com/docs/latest/c_gs_3.html#minor-embedding
It is really difficult to comment on errors such as the TypeError you mentioned without a complete minimal code example, reproduction steps, and the stack trace. That said, it could be just a small error in calling the embedding function.
The find_clique_embedding is slightly different from the find_embedding function, as the latter finds an embedding for your specific problem, rather than the embedding of a fully connected graph.
This community post has some information about using the find_embedding function with a given QPU:
https://support.dwavesys.com/hc/en-us/community/posts/360029524913/comments/360004850173
Feasibility in solutions is very problem-dependent. The best way to approach this is by starting with a small problem, proving to yourself that a feasible solution exists by looking at inputs and outputs, and then incrementally growing the problem size and complexity. It is possible that a bug gets introduced that makes a feasible solution impossible, so it is important to be very careful while expanding the problem size and complexity.
All of that said, we would highly recommend using the hybrid solvers, as they allow for problems larger than the QPU, and deal with the embedding and tuning steps automatically. Please take a look at our documentation for more information:
https://docs.ocean.dwavesys.com/en/latest/overview/hybrid.html
Thank you again for reaching out and please feel free to follow up with questions.
Please sign in to leave a comment.