pyquil
pyquil copied to clipboard
Inconsistence of the measurement data format between the result from simulators and that from QPUs
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
If more classical bits are declared than the number of qubits measured, the simulators and the QPUs return results in different formats. In particular, the QPU results contain the unused classical bits with random integer numbers. The simulator returns only the bits that are used in the measurement.
How to Reproduce
Otherwise, just fill out the "Code Snippet" and "Error Output" sections below.
Code Snippet
import pyquil as pq
p = pq.Program()
p += pq.gates.H(26)
p += pq.gates.H(27)
ro = p.declare('ro', 'BIT', 3)
p += pq.gates.MEASURE(26, ro[1])
p += pq.gates.MEASURE(27, ro[2])
qc = pq.get_qc(name='Aspen-11', as_qvm=True)
p_compiled = qc.compiler.quil_to_native_quil(p, protoquil=True)
p_compiled.wrap_in_numshots_loop(10)
p_compiled = qc.compiler.native_quil_to_executable(p_compiled)
results = qc.run(p_compiled)
print(results.readout_data.get('ro'))
qc = pq.get_qc(name='Aspen-11', as_qvm=False)
p_compiled = qc.compiler.quil_to_native_quil(p, protoquil=True)
p_compiled.wrap_in_numshots_loop(10)
p_compiled = qc.compiler.native_quil_to_executable(p_compiled)
results = qc.run(p_compiled)
print(results.readout_data.get('ro'))
Error Output
# simulator result
[[1 0]
[0 1]
[1 1]
[1 0]
[0 1]
[1 1]
[0 0]
[0 1]
[0 1]
[0 1]]
# QPU result
[[ 94489301501344 1 1]
[140215028296440 1 1]
[ 94489301688832 0 1]
[ 3 0 1]
[ 0 1 0]
[ 94489301689024 1 0]
[ 275 0 0]
[ 4294967295 0 0]
[ 1 1 1]
[ 0 1 1]]
Environment Context
Operating System: qcs pyQuil v3 jupyterlab
Python Version (python -V):
Python 3.8.6
Quilc Version (quilc --version):
1.26.0 [cfd8748]
QVM Version (qvm --version):
1.17.2 [266c11e]
Python Environment Details (pip freeze or conda list):
alembic @ file:///home/conda/feedstock_root/build_artifacts/alembic_1599849174714/work
appdirs==1.4.4
argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1605217004767/work
async-generator==1.10
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1605083924122/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache==1.6.1
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1601745390275/work
bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1600454382015/work
blinker==1.4
bokeh @ file:///home/conda/feedstock_root/build_artifacts/bokeh_1606141192957/work
Bottleneck @ file:///home/conda/feedstock_root/build_artifacts/bottleneck_1602497270979/work
brotlipy==0.7.0
cached-property==1.5.1
cachetools==4.2.4
certifi==2021.5.30
certipy==0.1.3
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1606601123836/work
chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1602255302199/work
charset-normalizer==2.0.12
cirq==0.12.0
cirq-aqt==0.12.0
cirq-core==0.12.0
cirq-google==0.12.0
cirq-ionq==0.12.0
cirq-pasqal==0.12.0
cirq-rigetti==0.12.0
cirq-web==0.12.0
click==7.1.2
cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1598400192773/work
colorama==0.4.4
conda==4.9.2
conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1602876795040/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1604179079864/work
cycler==0.10.0
Cython @ file:///home/conda/feedstock_root/build_artifacts/cython_1602367295094/work
cytoolz==0.11.0
dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1602029610262/work
decorator==4.4.2
defusedxml==0.6.0
dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1604312823872/work
distlib==0.3.4
distributed @ file:///home/conda/feedstock_root/build_artifacts/distributed_1604508001840/work
dlx==1.0.4
docplex==2.20.204
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1605121927639/work/dist/entrypoints-0.3-py2.py3-none-any.whl
fastcore==1.3.29
fastdtw==0.3.4
fastjsonschema==2.15.3
filelock==3.6.0
fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1602700749102/work
gitdb==4.0.9
GitPython==3.1.27
gmpy2==2.1.0b1
google-api-core==1.31.5
google-auth==1.35.0
googleapis-common-protos==1.55.1b1
grpcio==1.45.0rc1
h11==0.9.0
h5py @ file:///home/conda/feedstock_root/build_artifacts/h5py_1604753633781/work
HeapDict==1.0.1
httpcore==0.11.1
httpx==0.15.5
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1593328102638/work
imagecodecs @ file:///home/conda/feedstock_root/build_artifacts/imagecodecs_1602637304523/work
imageio @ file:///home/conda/feedstock_root/build_artifacts/imageio_1594044661732/work
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1606885585839/work
inflection==0.5.1
ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1605455374814/work/dist/ipykernel-5.3.4-py3-none-any.whl
ipympl @ file:///home/conda/feedstock_root/build_artifacts/ipympl_1599815557260/work
ipython==7.32.0
ipython-genutils==0.2.0
ipywidgets @ file:///home/conda/feedstock_root/build_artifacts/ipywidgets_1599554010055/work
iso8601==0.1.16
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1605054524035/work
Jinja2==2.11.2
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1601671685479/work
json5 @ file:///home/conda/feedstock_root/build_artifacts/json5_1600692310011/work
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema_1602551949684/work
jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1598486169312/work
jupyter-core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1605735009305/work
jupyter-telemetry @ file:///home/conda/feedstock_root/build_artifacts/jupyter_telemetry_1605173804246/work
jupyterhub @ file:///home/conda/feedstock_root/build_artifacts/jupyterhub-feedstock_1606489947389/work
jupyterlab==2.2.9
jupyterlab-git==0.23.2
jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1601375948261/work
jupyterlab-server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1593951277307/work
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1604322295622/work
lark==0.11.3
llvmlite==0.34.0
locket==0.2.0
lxml==4.8.0
Mako @ file:///home/conda/feedstock_root/build_artifacts/mako_1595925083607/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1602267312178/work
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1605180228501/work
matplotlib-inline==0.1.3
mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1605115651871/work
mock @ file:///home/conda/feedstock_root/build_artifacts/mock_1602394922444/work
more-itertools==8.12.0
mpmath==1.1.0
msgpack==0.6.2
multitasking==0.0.10
nb-conda-kernels @ file:///home/conda/feedstock_root/build_artifacts/nb_conda_kernels_1603235536649/work
nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1602859080374/work
nbconvert==5.6.1
nbdev==1.1.3
nbdime==2.1.1
nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1602732862338/work
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1605195931949/work
networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1598210780226/work
notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1605103633466/work
ntlm-auth==1.5.0
numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1599084802945/work
numexpr @ file:///home/conda/feedstock_root/build_artifacts/numexpr_1602670550279/work
numpy==1.22.3
oauthlib==3.0.1
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1602866521163/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1589925210001/work
pamela==1.0.0
pandas==1.1.4
pandocfilters==1.4.2
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1595548966091/work
partd==1.1.0
patsy==0.5.1
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1604748700719/work
plotly==4.13.0
ply==3.11
prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1605543085815/work
prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1605053337398/work
protobuf==3.13.0
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1603570988815/work
ptyprocess==0.6.0
py==1.11.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybind11==2.9.1
pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1602277853001/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1593275161868/work
pycurl==7.43.0.6
pydantic==1.8.2
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1603558917696/work
PyJWT==1.7.1
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1606535649775/work
pyparsing==2.4.7
pyquil==3.0.1
pyrsistent @ file:///home/conda/feedstock_root/build_artifacts/pyrsistent_1605115595652/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1602326928339/work
python-constraint==1.4.0
python-dateutil==2.8.1
python-editor==1.0.4
python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1602545356084/work
python-rapidjson==1.6
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1604321279890/work
PyWavelets @ file:///home/conda/feedstock_root/build_artifacts/pywavelets_1602504439440/work
PyYAML==5.3.1
pyzmq==20.0.0
qcs-api-client==0.8.0
qiskit==0.27.0
qiskit-aer==0.8.2
qiskit-aqua==0.9.2
qiskit-ibmq-provider==0.14.0
qiskit-ignis==0.6.0
qiskit-rigetti==0.4.5
qiskit-terra==0.17.4
Quandl==3.7.0
requests==2.27.1
requests-ntlm==1.1.0
retry==0.9.2
retrying==1.3.3
retworkx==0.11.0
rfc3339==6.2
rfc3986==1.5.0
rpcq==3.9.2
rpy2 @ file:///home/conda/feedstock_root/build_artifacts/rpy2_1606403672356/work
rsa==4.8
ruamel-yaml-conda @ file:///home/conda/feedstock_root/build_artifacts/ruamel_yaml_1602430332035/work
ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1605989946842/work
ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1605537770387/work
scikit-image==0.17.2
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1605985735074/work
scipy==1.8.0
seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-base_1604238753550/work
Send2Trash==1.5.0
simplegeneric==0.8.1
six==1.16.0
smmap==5.0.0
sniffio==1.2.0
sortedcontainers @ file:///home/conda/feedstock_root/build_artifacts/sortedcontainers_1605110889605/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1597680516047/work
SQLAlchemy @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy_1602547018298/work
statsmodels @ file:///home/conda/feedstock_root/build_artifacts/statsmodels_1604226979839/work
sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1606960536890/work
tables @ file:///home/conda/feedstock_root/build_artifacts/pytables_1603317058579/work
tblib==1.6.0
terminado @ file:///home/conda/feedstock_root/build_artifacts/terminado_1602679586280/work
testpath==0.4.4
threadpoolctl @ file:///tmp/tmp79xdzxkt/threadpoolctl-2.1.0-py3-none-any.whl
tifffile @ file:///home/conda/feedstock_root/build_artifacts/tifffile_1606474373635/work
toml==0.10.2
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1600973991856/work
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1604105045397/work
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1606492128227/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1602771532708/work
typing-extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1602702424206/work
tzlocal @ file:///home/conda/feedstock_root/build_artifacts/tzlocal_1588939190034/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1603125704209/work
vincent==0.4.4
virtualenv==20.2.1
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work
webencodings==0.5.1
websocket-client==1.3.1
widgetsnbextension @ file:///home/conda/feedstock_root/build_artifacts/widgetsnbextension_1605475534911/work
xlrd @ file:///home/conda/feedstock_root/build_artifacts/xlrd_1595712200082/work
yfinance==0.1.70
zict==2.0.0
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1603668650351/work
@andyliphys Thanks for the report. That's a good one, and I don't think I've seen it before. I'll take a closer look and see if this is a bug and can be fixed.
This is important to consider for v4: QVM and QPU should return results that are consistent in shape
This has been fixed in v4, with the appropriate amount of nuance.