Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug - for a large number of points #18

Closed
haoqian-hao opened this issue Mar 15, 2022 · 10 comments
Closed

bug - for a large number of points #18

haoqian-hao opened this issue Mar 15, 2022 · 10 comments

Comments

@haoqian-hao
Copy link

haoqian-hao commented Mar 15, 2022

I tried running this with 20 points on D'wave, but it gave me an error:
ValueError: no embedding found
is this because dwavebinarycsp can not solve a large dataset?

@arcondello
Copy link

Hi @haoqian-hao , probably the BQM that is made by dwavebinarycsp is too large for the QPU you are using. You should consider using one of our hybrid solvers.

@haoqian-hao
Copy link
Author

haoqian-hao commented Jun 18, 2022

Hi @arcondello, when I was using my dataset (the fraction that is laying on 0-1), it is not working correctly, it will assign the data point to all clusters (one of the results shows "0.15625,0_b': 1, '0.15625,0_g': 1, '0.15625,0_r': 1" ), it seems like the constraints in csp that penalise the coordinate can only be in one colour group is not strong enough, are there some ways to solve this? e.g., add chain_strength to the hybrid solver or add a coefficient or a penalty strength?

I appreciate any help you can provide.

@arcondello
Copy link

Which hybrid solver are you using? And are you still using dwavebinarycsp.stitch() to construct your BQM?

@haoqian-hao
Copy link
Author

@arcondello, I used LeapHybridSampler and got the lowest energy from the result followed by,

sampler = LeapHybridSampler()    
sampleset = sampler.sample(bqm) 
best_answer = list(sampleset.data(["sample", "energy"]))[0].sample

Yes, I am using dwavebinarycsp.stitch() to construct BQM

@arcondello
Copy link

Hi @haoqian-hao, you can adjust the classical gap for the penalty models with dwavebinarycsp.stitch(csp, min_classical_gap=...), see min_classical_gap.

You might also try using our constrained quadratic model hybrid solver.

@haoqian-hao
Copy link
Author

haoqian-hao commented Jul 14, 2022

Hi @arcondello, thank you for helping me for this long time.
I just wondering why

BQM that is made by dwavebinarycsp is too large for the QPU you are using

from my understanding, the qubits require for solving Clustering are
K * N, where K = the number of clusters and N is datapoints,
for the pure QPU like DW_2000Q_6, it has 2041 working qubits. Therefore, the DW_2000Q_6 should be able to handle ( N <= 2041 / K ) datapoint. However, from my testing, it can only handle ~10 for K=2. just wondering why this happened, the reason could be we can not fully access all of the qubits? just wondering should we set the hyperparameter which represents the number of qubits used?

@arcondello
Copy link

Hi @haoqian-hao, although the QPU has ~2000 working qubits, they are not all connected to eachother. Therefore, solving problems with higher connectivity requires something called embedding. See D-Wave QPU Architecture: Topologies for a discussion of what this means for solving problems.

Also worth noting that the hybrid solvers do not have these limits.

@billwisotsky
Copy link

Hello. I have been playing around with this sample. Once I go above 18 tuples I get the following error. Not sure what this means. The sampler, sampleset and best_sampler have not been changed from what is in the example,

Thanks in advance.

ValueError Traceback (most recent call last)
Input In [18], in <cell line: 2>()
1 clustered_filename = "clustered_points.png"
----> 2 cluster_points(scattered_points, clustered_filename, False)

File ~\OneDrive - SAS\Quantum\DWave\Notebooks\clustering-master\clustering_SAS.py:89, in cluster_points(scattered_points, filename, problem_inspector)
86 weight = -math.cos(d*math.pi)
88 # Apply weights to BQM
---> 89 bqm.add_interaction(coord0.r, coord1.r, weight)
90 bqm.add_interaction(coord0.g, coord1.g, weight)
91 bqm.add_interaction(coord0.b, coord1.b, weight)

File ~.conda\envs\DWave\lib\site-packages\dimod\binary\binary_quadratic_model.py:888, in BinaryQuadraticModel.add_interaction(self, *args, **kwargs)
886 def add_interaction(self, *args, **kwargs):
887 """Alias for :meth:.add_quadratic."""
--> 888 return self.add_quadratic(*args, **kwargs)

File ~.conda\envs\DWave\lib\site-packages\dimod\binary\cybqm\cybqm_template.pyx.pxi:249, in dimod.binary.cybqm.cybqm_float64.cyBQM_template.add_quadratic()

ValueError: '51.0,38.0_r' cannot have an interaction with itself

@billwisotsky
Copy link

All fixed. Worked with Dwave today and looks like since I using integers, there was another pair with the same values which through the error. Once I added decimal places I got past this error.

@billwisotsky
Copy link

billwisotsky commented Jan 27, 2023

Has anyone gotten this to work with large samples. I have run through this an tried the potential fixes mentioned above (i.e. min_classical_gap) and nothing has worked. min_classical_gap would just generate errors below. It seems anything over sample size of 9 per cluster and the clustering breaks down. Attached is a graph with 100. There are visually 3 clusters, but they are only being assigned to one cluster name red.

Traceback (most recent call last):
File "c:/Users/bill/OneDrive/Quantum/DWave/Notebooks/clustering-master/example_clusters.py", line 53, in
nine_points_clustered

cluster_points(scattered_points, clustered_filename, args.problem_inspector)

File "c:\Users\bill\OneDrive\Quantum\DWave\Notebooks\clustering-master\clustering.py", line 124, in cluster_points
groupings = get_groupings(best_sample)
File "c:\Users\bill\OneDrive\Quantum\DWave\Notebooks\clustering-master\utilities.py", line 36, in get_groupings
coord, color = label.split("_")
ValueError: not enough values to unpack (expected 2, got 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants