pyquil
pyquil copied to clipboard
Unable to display latex circuit
Pre-Report Checklist
- [x] I am running the latest versions of pyQuil and the Forest SDK
- [x] I checked to make sure that this bug has not already been reported
Issue Description
Program unable to display circuit with the following error message: ValueError: Unable to render instruction XY(pi) 21 36 which targets non-adjacent qubits.
. This is clearly wrong as the 2 qubits are indeed adjacent to each other on the Aspen-9 topology.
Code Snippet
program = qnn_circuit(n_qubits= 8 , n_features = 16, n_parameters = 15)
qc = get_qc('Aspen-9')
native = qc.compiler.quil_to_native_quil(program)
pyquil.latex.display(native)
Note that pyquil.latex.display(program)
yields the image below but displaying native
causes the issue.

Error Output
ValueError: Unable to render instruction XY(pi) 21 36 which targets non-adjacent qubits.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/var/folders/cx/22y072mx1gjcqtb64f6gq8_00000gq/T/ipykernel_10570/2574794935.py in <module>
2 native = qc.compiler.quil_to_native_quil(program)
3 # print(native)
----> 4 pyquil.latex.display(native)
~/Desktop/Rigetti /Code/qnns-ttn-aca/qnns_pyquil/lib/python3.9/site-packages/pyquil/latex/_ipython.py in display(circuit, settings, **image_options)
58 with tempfile.TemporaryDirectory() as tmpdir:
59 with open(os.path.join(tmpdir, "diagram.tex"), "w") as texfile:
---> 60 texfile.write(to_latex(circuit, settings))
61
62 result = subprocess.run(
~/Desktop/Rigetti /Code/qnns-ttn-aca/qnns_pyquil/lib/python3.9/site-packages/pyquil/latex/_main.py in to_latex(circuit, settings)
55 text = header()
56 text += "\n"
---> 57 text += body(circuit, settings)
58 text += "\n"
59 text += footer()
~/Desktop/Rigetti /Code/qnns-ttn-aca/qnns_pyquil/lib/python3.9/site-packages/pyquil/latex/_main.py in body(circuit, settings)
101 """
102
--> 103 diagram = DiagramBuilder(circuit, settings).build()
104
105 # flush lines
~/Desktop/Rigetti /Code/qnns-ttn-aca/qnns_pyquil/lib/python3.9/site-packages/pyquil/latex/_diagram.py in build(self)
378 self._build_custom_source_target_op()
379 else:
--> 380 self._build_generic_unitary()
381 elif isinstance(instr, UNSUPPORTED_INSTRUCTION_CLASSES):
382 raise ValueError(
~/Desktop/Rigetti /Code/qnns-ttn-aca/qnns_pyquil/lib/python3.9/site-packages/pyquil/latex/_diagram.py in _build_generic_unitary(self)
501 target_qubits = qubits[controls:]
502 if not self.diagram.is_interval(sorted(target_qubits)):
--> 503 raise ValueError(f"Unable to render instruction {instr} which targets non-adjacent qubits.")
504
505 for q in control_qubits:
ValueError: Unable to render instruction XY(pi) 21 36 which targets non-adjacent qubits.
Environment Context
Operating System: MacOS Big Sur Version 11.5.2
Python Version (python -V
): 3.9.6
Quilc Version (quilc --version
): 1.23.0
QVM Version (qvm --version
): 1.17.1
Python Environment Details (pip freeze
or conda list
):
appnope==0.1.2
argon2-cffi==20.1.0
attrs==20.3.0
backcall==0.2.0
bleach==4.0.0
certifi==2021.5.30
cffi==1.14.6
charset-normalizer==2.0.4
cryptography==3.4.7
cycler==0.10.0
debugpy==1.4.1
decorator==5.0.9
defusedxml==0.7.1
dill==0.3.4
dlx==1.0.4
docplex==2.21.207
entrypoints==0.3
fastdtw==0.3.4
fastjsonschema==2.15.1
h11==0.9.0
h5py==3.2.1
httpcore==0.11.1
httpx==0.15.5
idna==3.2
inflection==0.5.1
ipykernel==6.2.0
ipython==7.26.0
ipython-genutils==0.2.0
iso8601==0.1.16
jedi==0.18.0
Jinja2==3.0.1
joblib==1.0.1
jsonschema==3.2.0
jupyter-client==6.1.12
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
kiwisolver==1.3.1
lark==0.11.3
lxml==4.6.3
MarkupSafe==2.0.1
matplotlib==3.4.3
matplotlib-inline==0.1.2
mistune==0.8.4
more-itertools==8.8.0
mpmath==1.2.1
msgpack==0.6.2
multitasking==0.0.9
nbclient==0.5.4
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
networkx==2.6.2
noisyopt==0.2.2
notebook==6.4.3
ntlm-auth==1.5.0
numpy==1.21.2
packaging==21.0
pandas==1.3.2
pandocfilters==1.4.3
parso==0.8.2
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.3.1
ply==3.11
prometheus-client==0.11.0
prompt-toolkit==3.0.19
psutil==5.8.0
ptyprocess==0.7.0
py==1.10.0
pybind11==2.7.1
pycparser==2.20
pydantic==1.8.2
Pygments==2.10.0
PyJWT==1.7.1
pyparsing==2.4.7
pyprojroot==0.2.0
pyquil==3.0.0
pyrsistent==0.18.0
python-constraint==1.4.0
python-dateutil==2.8.2
python-rapidjson==1.4
pytz==2021.1
pyzmq==22.2.1
qcs-api-client==0.8.0
qiskit==0.29.0
qiskit-aer==0.8.2
qiskit-aqua==0.9.4
qiskit-ibmq-provider==0.16.0
qiskit-ignis==0.6.0
qiskit-terra==0.18.1
Quandl==3.6.1
requests==2.26.0
requests-ntlm==1.1.0
retry==0.9.2
retrying==1.3.3
retworkx==0.9.0
rfc3339==6.2
rfc3986==1.5.0
rpcq==3.9.2
ruamel.yaml==0.17.10
ruamel.yaml.clib==0.2.6
scikit-learn==0.24.2
scipy==1.7.1
seaborn==0.11.2
Send2Trash==1.8.0
six==1.16.0
sniffio==1.2.0
symengine==0.7.2
sympy==1.8
terminado==0.11.0
testpath==0.5.0
threadpoolctl==2.2.0
toml==0.10.2
tornado==6.1
traitlets==5.0.5
tweedledum==1.1.0
typing-extensions==3.10.0.0
urllib3==1.26.6
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.2.1
yfinance==0.1.62