quantastica / quantum-circuit

Quantum Circuit Simulator implemented in JavaScript
MIT License
243 stars 47 forks source link

Error at First Access to Quantum-Circuit.COM using QPS Client #2

Closed claudefalbriard closed 5 years ago

claudefalbriard commented 5 years ago

My runtime platform is Intel Ubuntu Linux 17 with Anaconda Python 3.6

Installing and Testing Quantum-Circuit API Installation according instructions was OK Upgrade of Rigetti forest SDK 2.2.2 and Pyquil was OK

Simulation of a small circuit via web was OK (Hadamard & CNOT entanglement 50%, 50%) is OK Qubit Measured Probability
q0 0 0.5
q1 0 0.5

Starting the daemon manually at Anaconda Linux Console with environment set to Python 3.6 qps-client --backends rigetti-qvm

Log:

Quantum Programming Studio Client Connected. Account: myid@myprovider.com Password: Login successful. Backends: rigetti-qvm

Web GUI


Run on Rigetti QCS or Forest SDK QMI 131.0.217.166 Test on QVM

Error message: During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "/home/claude/anaconda3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/claude/anaconda3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/claude/anaconda3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/claude/anaconda3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/home/claude/anaconda3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connection.py", line 181, in connect conn = self._new_conn() File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa09c95c630>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/claude/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 449, in send timeout=timeout File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen response_kw) File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen response_kw) File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen **response_kw) File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/home/claude/anaconda3/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /qvm (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa09c95c630>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 15, in File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_error_reporting.py", line 238, in wrapper val = func(*args, kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_quantum_computer.py", line 152, in run return self.qam.run() \ File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_error_reporting.py", line 238, in wrapper val = func(*args, *kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_qvm.py", line 481, in run random_seed=self.random_seed)['ro'] File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_error_reporting.py", line 238, in wrapper val = func(args, kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_base_connection.py", line 362, in _qvm_run response = post_json(self.session, self.sync_endpoint + "/qvm", payload) File "/home/claude/anaconda3/lib/python3.6/site-packages/pyquil/api/_base_connection.py", line 56, in post_json res = session.post(url, json=json) File "/home/claude/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 581, in post return self.request('POST', url, data=data, json=json, kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "/home/claude/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /qvm (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa09c95c630>: Failed to establish a new connection: [Errno 111] Connection refused',))


Looks like some local environment issue between the Firefox browser and Python. Any hints how to fix this API connection is welcome.
Regards, Claude

perak commented 5 years ago

@claudefalbriard is your qvm running? It should be running in another terminal, with following command:

qvm -c -S
perak commented 5 years ago

By the way, not related to this issue: there is a problem with FireFox - it doesn't show scrollbars in some pages, will be fixed. If you notice please report (in a new issue). Thanks 👍

falbriard commented 5 years ago

Thanks for the quick support. Indeed the process started with the command: qvm -c -S fixed the browser connectivity. After starting the process I get a log as followed:

127.0.0.1 - [2019-01-17 11:15:08] "POST /qvm HTTP/1.1" 200 12 "-" "python-requests/2.21.0" [2019-01-17 11:19:57 [INFO]] [127.0.0.1 Session:2] Got "multishot" request from API key/User ID: NIL / NIL [2019-01-17 11:19:57 [INFO]] [127.0.0.1 Session:2] Making qvm of 2 qubits [2019-01-17 11:19:57 [INFO]] [127.0.0.1 Session:2] Running experiment with 1 trial on PURE-STATE-QVM [2019-01-17 11:19:57 [INFO]] [127.0.0.1 Session:2] Finished in 3 ms 127.0.0.1 - [2019-01-17 11:19:57] "POST /qvm HTTP/1.1" 200 12 "-" "python-requests/2.21.0"

and at the browser console ouput log: [[0]]

Question: For [ run ] where do I get the probability value for the two qubits that are part of my circuit, as shown at the simulation screen?

Yet another suggestion: A clear output window button could be helpful.

Thanks for clarification.

perak commented 5 years ago

@falbriard all looks good now :)

Browser console output shows measurement (looks like you have "measurement" gate on single qubit, thus you have single number as output: [[0]]).

Currently, qps-client is set to return output from measurement, it doesn't print probabilities. That functionality is planned but not implemented yet (idea is to have similar screen like "Simulate -> Browser" screen).

perak commented 5 years ago

(print probabilities is supported by Forest SDK/QVM but qps-client is not set to print that)

falbriard commented 5 years ago

Thanks so much, problem isolated and fixed. I've manually updated the QASM code to generate two classical registers for storing the results of the measurements on two entangled qubits. Here is what I've done:

Result: [[0 0]]

QASM Code: OPENQASM 2.0; include "qelib1.inc"; qreg q[2]; creg r[2]; h q[0]; cx q[0], q[1]; measure q[0] -> c[1]; measure q[1] -> r[1];

As previously tested the result is OK. Both of qubits flip its state together in an aleatory result.

Suggestion: The creation of a additional classical register could eventually be automated by a "drag" of the measurement arrow, to a point below the existing registers, much the way as CNOT is creating a second qubit.

perak commented 5 years ago

@falbriard it is possible to manipulate registers via Drag & Drop interface. Please see following video:

https://www.youtube.com/watch?v=4SfnwMr2aWg

There is green "plus" at the right side of the screen, next to word "Registers" (when no gate is selected) which allows you to add registers.

falbriard commented 5 years ago

Sorry, my fault, watched in the wrong screen corner. This is perfect and gives the control. thanks. Please close this issue, its solved. Will enjoy this tool, specially for training and education.

perak commented 5 years ago

Great, closing first issue! Glad you like it! Enjoy!