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

Uncaught TypeError: Cannot read property 'length' of undefined #39

Closed
mdecandia opened this issue Jan 28, 2020 · 6 comments
Closed

Uncaught TypeError: Cannot read property 'length' of undefined #39

mdecandia opened this issue Jan 28, 2020 · 6 comments

Comments

@mdecandia
Copy link
Member

Problem Inspector fails to start up for the below problem. It shows a blue screen and an error in the console. Unfortunately, I have not found what exactly causes the issue in this problem.

Problem:

import sys
import dimod
import dwave.inspector
from minorminer import find_embedding
from dwave.cloud import Client
from dwave.embedding import embed_bqm, unembed_sampleset
from dwave.embedding.utils import edgelist_to_adjacency
import networkx as nx
import dwave_networkx as dnx
import numpy as np
from dwave.system import DWaveSampler, EmbeddingComposite,FixedEmbeddingComposite

sampler = EmbeddingComposite(DWaveSampler(solver=dict(qpu=True)))
Q = {('x', 'x'): -1, ('x', 'z'): 2, ('z', 'x'): 0, ('z', 'z'): -1}

sampler_embedded = FixedEmbeddingComposite(sampler, {'x': [4], 'z': [0, 128, 256, 384, 512, 640, 768]})
sampleset = sampler_embedded.sample_qubo(Q, num_reads=5000, chain_strength=1)
sampleset.info["embedding"] = {'x': [4], 'z': [0, 128, 256, 384, 512, 640, 768]}

dwave.inspector.show(dimod.BQM.from_qubo(Q), sampleset, sampler_embedded)

Console Error:

Uncaught TypeError: Cannot read property 'length' of undefined
    at main.8f0edd8b.chunk.js:1
    at main.8f0edd8b.chunk.js:1
    at Map.forEach (<anonymous>)
    at c.iterateNodes (main.8f0edd8b.chunk.js:1)
    at Object.layoutVars (main.8f0edd8b.chunk.js:1)
    at Object.<anonymous> (main.8f0edd8b.chunk.js:1)
    at v.applyLayoutFunction (main.8f0edd8b.chunk.js:1)
    at main.8f0edd8b.chunk.js:1
    at main.8f0edd8b.chunk.js:1
    at Array.forEach (<anonymous>)

Screenshot:
Screen Shot 2020-01-27 at 16 58 52 PM

@randomir
Copy link
Member

The problem here boils down to nested embedding composites. First you define:

sampler = EmbeddingComposite(DWaveSampler(...))

and then:

sampler_embedded = FixedEmbeddingComposite(sampler, ...)

Not sure if that was your intent. If one composite is removed (probably makes sense to remove the first one), then everything works (and you can avoid manually setting the embedding on sampleset, that's not needed).

The lesson learnt is we need to compose embeddings returned by embedding composites when return_embedding=True, and when embedding composites are nested. Thus, I'll open an issue on dwave-system.

@arcondello
Copy link
Member

One other approach that was discussed back in the requirements stage would be to give the inspector the ability to show multiple intermediate BQMs. So logical -> intermdiate -> source. This deemed too much work for R1 but in the context of debugging it would (IMO) be more useful than composed embeddings, in that embedding warnings etc can be embedding specific. Of course there are another whole class of warnings that come out of embedding interactions, in which case the composed embeddings are useful 🤷‍♂

@randomir
Copy link
Member

Yup, that's the obvious next step after plot-style inspector -- the dashboard-style inspector, where user would be able to browse all captured data and inspect it...

@mdecandia
Copy link
Member Author

Thanks! My bad. That was somewhat unintentional. And it does work when removing the EmbeddingComposite. Shall I close this issue or wait for that one to be resolved?

Compose embedding when returning it #251

@randomir
Copy link
Member

It's not clear how to handle nested embedding composites transparently (see comments on the linked dwave-system issue).

I think the best solution will be the dashboard-style inspector, where user will be able to browse problems/solutions, including intermediate steps. But that's not going to be implemented anytime soon.

So, I'd close this one in favor of #40.

@mdecandia
Copy link
Member Author

That dashboard-style inspector solution sounds pretty cool. But yeah, I don't think we'll see that anytime soon.

Closing ticket.

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