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

Sending Scripts to the QPU #32

Closed
Bhaney44 opened this issue Jul 14, 2019 · 5 comments
Closed

Sending Scripts to the QPU #32

Bhaney44 opened this issue Jul 14, 2019 · 5 comments

Comments

@Bhaney44
Copy link

Description
A clear and concise description of what the bug is.
I keep into the same problem. After I complete the configuration and confirm my computer is linked to the QPU via dwave ping, I am unable to begin sending scripts to the QPU. Indeed, because I have to create a virtual environment to connect to the QPU, none of the scripts on my computer are available to send. Further, when I try to code directly from the command line in Python the return states the module isn't present.

To Reproduce
Stack Overflow provides an excellent guide on how to create a Minimal, Complete and Verifiable example.

For example, once I create a configuration file, I may run $ python:

import networkx as nx

But, the return is

ImportError: No module named networkx

Expected behavior
A clear and concise description of what you expected to happen.

I expected once I was in the virtual environment to have access to the modules. Alternatively, I would want to be able to send scripts to the QPU. I can run some programs through the Jupyter Notebook, but a lot of the modules - like QBoost - aren't available. I would appreciate any advice on how to proceed.

Environment:

  • OS: [Ubuntu 16.04.4 LTS]
  • Python version: [e.g. 3.7.0]

Additional context
Add any other context about the problem here.

With thanks,

Brian

arcondello pushed a commit to arcondello/dwave-ocean-sdk that referenced this issue Aug 20, 2019
@davage
Copy link

davage commented Sep 10, 2019

Hi @Bhaney44,

Were you able to set up your virtualenv?

After setting it up, did you install the dwave-ocean-sdk?

The networkx library should be installed as a dependency with dwave-ocean-sdk.

Are you able to import dimod?
import dimod

Best regards,

Dave.

@Bhaney44
Copy link
Author

Yeah I'm all good. Thanks @davage.

@Bhaney44 Bhaney44 reopened this Sep 12, 2019
@Bhaney44
Copy link
Author

I was wrong, I tried tonight and had the same problem. The issue is I can run dwave ping and get a fine response. I can also run a random problem. However, the problem is I cannot send python scripts to the QPU. The Docs skip over how to actually send a problem to the QPU. So, here in the docs is the problem. While I can set up a config, but the docs say

Alternatively, from within your code or a Python interpreter you can query solvers available for a SAPI URL and API token using dwave-cloud-client get_solvers() function.

But, I'm struggling to accomplish this. The code says:

from dwave.cloud import Client
client = Client.from_config(token='ABC-123456789123456789123456789')
client.get_solvers()

But, that returns an error for me. Traditionally, if you type python in the command line you can code in python, but that doesn't work with the QPU. Similarly, you can type Python file_name.py to run a file from the command line on the CPU. I want to get to here:

from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite
sampler = EmbeddingComposite(DWaveSampler())
response = sampler.sample_ising({'a': -0.5, 'b': 1.0}, {('a', 'b'): -1})
response.data_vectors['energy']  

Either directly from the command line or even better if I can save this as a .py file and simply send it to the QPU. But, with the QPU, there isn't an intuitive way to send or run scripts. In short, I have scripts written - how do I send those python scripts to the QPU? In other words how do you get from sending a dwave ping to sending a Python script.

I hope this makes sense. Thanks again for your help. I sincerely appreciate it.

Brian

@davage
Copy link

davage commented Sep 12, 2019

So for the DWaveSampler, every time you run sample() or sample_ising(), you are actually sending the problem to the QPU and the result returned is the sample taken from the QPU.

The first part of the code with the client, is probably unnecessary.
Once you have run the dwave config create command, set up your information, and the dwave ping command works, you should be able to create a DWaveSampler without any parameters.

You should be able to just run the second block of code as is, without the client set up.
The client is for more advanced functionality that most users will likely not need.
At least not to start out with.
The functionality is similar, and some of it is used by DWaveSampler if I'm not mistaken.

The dwave ping command will work as long as your virtual environment is activated and your config is set up properly, and as long as dwave ping works, you should be able to send problems to the QPU.

@Bhaney44
Copy link
Author

That makes a lot of sense, thanks. You explained that very clearly, I sincerely appreciate it.

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

2 participants