You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running the latest versions of pyQuil and the Forest SDK
I checked to make sure that this bug has not already been reported
Issue Description
I am in a Python environment with Cirq and pyquil==3.5.4. This is the latest possible version of pyquil supported by cirq-rigetti at the moment, until this PR gets merged.
I spin up QVM & quilc servers from the Docker images (see commands below).
When I run get_qc("2q-noisy-qvm") I get an UnknownApiError.
Is pyquil v3 still compatible with the QVM?
How to Reproduce
Code Snippet
frompyquilimportget_qcget_qc("2q-noisy-qvm")
Error Output
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm_client.py:280, in QVMClient._parse_error(res)
279 try:
--> 280 body = res.json()
281 except JSONDecodeError:
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/httpx/_models.py:756, in Response.json(self, **kwargs)
755 return jsonlib.loads(self.content.decode(encoding), **kwargs)
--> 756 return jsonlib.loads(self.text, **kwargs)
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of ``s`` (a ``str`` instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
UnknownApiError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from pyquil import get_qc; get_qc("2q-noisy-qvm")
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_quantum_computer.py:822, in get_qc(***failed resolving arguments***)
820 if qvm_type is None:
821 raise ValueError("Please name a valid quantum_processor or run as a QVM")
--> 822 return _get_unrestricted_qvm(
823 client_configuration=client_configuration,
824 name=name,
825 noisy=noisy,
826 n_qubits=n_qubits,
827 qvm_type=qvm_type,
828 compiler_timeout=compiler_timeout,
829 execution_timeout=execution_timeout,
830 )
832 # 3. Check for "9q-square" qvm
833 if prefix == "9q-square":
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_quantum_computer.py:669, in _get_unrestricted_qvm(client_configuration, name, noisy, n_qubits, qvm_type, compiler_timeout, execution_timeout)
654 """
655 A qvm with a fully-connected topology.
656
(...)
666 :return: A pre-configured QuantumComputer
667 """
668 topology = nx.complete_graph(n_qubits)
--> 669 return _get_qvm_with_topology(
670 client_configuration=client_configuration,
671 name=name,
672 topology=topology,
673 noisy=noisy,
674 qvm_type=qvm_type,
675 compiler_timeout=compiler_timeout,
676 execution_timeout=execution_timeout,
677 )
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_quantum_computer.py:598, in _get_qvm_with_topology(client_configuration, name, topology, noisy, qvm_type, compiler_timeout, execution_timeout)
596 else:
597 noise_model = None
--> 598 return _get_qvm_qc(
599 client_configuration=client_configuration,
600 name=name,
601 qvm_type=qvm_type,
602 quantum_processor=quantum_processor,
603 noise_model=noise_model,
604 compiler_timeout=compiler_timeout,
605 execution_timeout=execution_timeout,
606 )
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_quantum_computer.py:551, in _get_qvm_qc(client_configuration, name, qvm_type, quantum_processor, compiler_timeout, execution_timeout, noise_model)
525 def _get_qvm_qc(
526 *,
527 client_configuration: QCSClientConfiguration,
(...)
533 noise_model: Optional[NoiseModel],
534 ) -> QuantumComputer:
535 """Construct a QuantumComputer backed by a QVM.
536
537 This is a minimal wrapper over the QuantumComputer, QVM, and QVMCompiler constructors.
(...)
546 :return: A QuantumComputer backed by a QVM with the above options.
547 """
549 return QuantumComputer(
550 name=name,
--> 551 qam=_get_qvm_or_pyqvm(
552 client_configuration=client_configuration,
553 qvm_type=qvm_type,
554 noise_model=noise_model,
555 quantum_processor=quantum_processor,
556 execution_timeout=execution_timeout,
557 ),
558 compiler=QVMCompiler(
559 quantum_processor=quantum_processor,
560 timeout=compiler_timeout,
561 client_configuration=client_configuration,
562 ),
563 )
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_quantum_computer.py:517, in _get_qvm_or_pyqvm(client_configuration, qvm_type, noise_model, quantum_processor, execution_timeout)
508 def _get_qvm_or_pyqvm(
509 *,
510 client_configuration: QCSClientConfiguration,
(...)
514 execution_timeout: float,
515 ) -> Union[QVM, PyQVM]:
516 if qvm_type == "qvm":
--> 517 return QVM(noise_model=noise_model, timeout=execution_timeout, client_configuration=client_configuration)
518 elif qvm_type == "pyqvm":
519 assert quantum_processor is not None
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm.py:116, in QVM.__init__(self, noise_model, gate_noise, measurement_noise, random_seed, timeout, client_configuration)
114 client_configuration = client_configuration or QCSClientConfiguration.load()
115 self._qvm_client = QVMClient(client_configuration=client_configuration, request_timeout=timeout)
--> 116 self.connect()
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm.py:120, in QVM.connect(self)
118 def connect(self) -> None:
119 try:
--> 120 version = self.get_version_info()
121 check_qvm_version(version)
122 except ConnectionError:
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm.py:175, in QVM.get_version_info(self)
169 def get_version_info(self) -> str:
170 """
171 Return version information for the QVM.
172
173 :return: String with version information
174 """
--> 175 return self._qvm_client.get_version()
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm_client.py:176, in QVMClient.get_version(self)
172 def get_version(self) -> str:
173 """
174 Get version info for QVM server.
175 """
--> 176 return self._post_json({"type": "version"}).text.split()[0]
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm_client.py:261, in QVMClient._post_json(self, json)
259 response = http.post("/", json=json)
260 if response.status_code >= 400:
--> 261 raise self._parse_error(response)
262 return response
File /opt/miniconda3/envs/mitiqenv/lib/python3.11/site-packages/pyquil/api/_qvm_client.py:282, in QVMClient._parse_error(res)
280 body = res.json()
281 except JSONDecodeError:
--> 282 raise UnknownApiError(res.text)
284 if "error_type" not in body:
285 raise UnknownApiError(str(body))
UnknownApiError:
I am running QVM on a port different than the default 5000, because of #1653. I was doing this by overriding the QVM url via the env variable QCS_SETTINGS_APPLICATIONS_QVM_URL mentioned here. The thing is.. this env variable used to have a different name (i.e., QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL) in pyQuil v3, which is the version I am using.
Snippet of working code from ipython:
In [2]: %envQCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL=http://127.0.0.1:5001env: QCS_SETTINGS_APPLICATIONS_PYQUIL_QVM_URL=http://127.0.0.1:5001In [3]: frompyquilimportget_qc
...: get_qc("2q-noisy-qvm")
Out[3]: QuantumComputer[name="2q-noisy-qvm"]
Pre-Report Checklist
Issue Description
I am in a Python environment with Cirq and pyquil==3.5.4. This is the latest possible version of pyquil supported by cirq-rigetti at the moment, until this PR gets merged.
I spin up QVM & quilc servers from the Docker images (see commands below).
When I run
get_qc("2q-noisy-qvm")
I get an UnknownApiError.Is pyquil v3 still compatible with the QVM?
How to Reproduce
Code Snippet
Error Output
Environment Context
Operating System: macOS 14.3.1 (23D60)
Python Version (
python -V
): Python 3.11.8Quilc Version (
quilc --version
): 1.26.0 [7aef642]Version comes from:
QVM Version (
qvm --version
): 1.17.2 [266c11e]Version comes from:
Python Environment Details (
pip freeze
orconda list
):It's basically a fresh environment for https://github.com/unitaryfund/mitiq
The text was updated successfully, but these errors were encountered: