m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
437 stars 201 forks source link

core device traceback decoding problem on Windows #394

Closed r-srinivas closed 8 years ago

r-srinivas commented 8 years ago

My device_db contains DDS entries like,

    "dds0": {
        "type": "local",
        "module": "artiq.coredevice.dds",
        "class": "AD9914",
        "arguments": {"bus_channel": 58, "channel": 0},
        "comment": "Comments work in DDS panel as well"
    },

And I'm running the following experiment,

from artiq.experiment import *

class DDS_Set(EnvExperiment):
    def build(self):

        self.setattr_device("core")
        self.setattr_device("core_dds")
        self.setattr_device("dds0")
        self.setattr_device("dds2")
        self.setattr_device("dds3")
        self.setattr_device("dds4")
        self.setattr_device("dds5")

    @kernel
    def run(self):
        with self.core_dds.batch:
            self.dds0.set(100*MHz)
            self.dds2.set(200*MHz)
            self.dds3.set(200*MHz)
            self.dds4.set(200*MHz)
            self.dds5.set(200*MHz)

The DDS bus channel is actually 50, not 58 as it was previously after the recent changes. I built a new bitstream and flashed the FPGA. If I run the experiment with the incorrect bus channel on windows, I get the following error message,

WARNING:worker(1149,dds_set.py):artiq.coredevice.comm_generic:Mismatch between g
ateware (1.0rc1+204.gfaa268e) and software (1.0rc2) versions
ERROR:worker(1149,dds_set.py):root:Terminating with exception (UnicodeDecodeErro
r: 'utf-8' codec can't decode byte 0xdd in position 324: invalid continuation by
te)
Traceback (most recent call last):
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\master\worker
_impl.py", line 231, in main
    exp_inst.run()
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\language\core
.py", line 192, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
re.py", line 108, in run
    self.comm.serve(object_map, symbolizer)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
mm_generic.py", line 527, in serve
    self._serve_exception(object_map, symbolizer)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
mm_generic.py", line 508, in _serve_exception
    traceback = list(reversed(symbolizer(backtrace))) + \
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
re.py", line 89, in <lambda>
    lambda addresses: target.symbolize(library, addresses)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\compiler\targ
ets.py", line 166, in symbolize
    library=library) \
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\compiler\targ
ets.py", line 39, in __enter__
    tempfiles["__stdout__"] = stdout.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 324: invali
d continuation byte
ERROR:master:artiq.master.scheduler:got worker exception in run stage, deleting
RID 1149

On linux, I get a more explicit error message,

WARNING:worker(3084,dds_set.py):artiq.coredevice.comm_generic:Mismatch between gateware (1.0rc1+204.gfaa268e) and software (1.0rc2) versions
ERROR:worker(3084,dds_set.py):root:Terminating with exception (DDSError: Attempted to use invalid DDS bus)
Core Device Traceback (most recent call last):
  File "/home/rabi/artiq-master/repository/dds_set.py", line 27, in artiq_worker_dds_set.DDS_Set.run (RA=0x16e8)
    with self.core_dds.batch:
  File "<artiq>/coredevice/dds.py", line 42, in artiq.coredevice.dds._BatchContextManager.__exit__ (RA=0xed8)
    self.core_dds.dds_batch_exit()
  File "<artiq>/coredevice/dds.py", line 71, in artiq.coredevice.dds.CoreDDS.dds_batch_exit (inlined)
    dds_batch_exit()
  File "/home/rabi/artiq-dev/artiq/artiq/runtime/dds.c", line 97, in dds_set_one
    artiq_raise_from_c("DDSError", "Attempted to use invalid DDS bus", 0, 0, 0);
artiq.coredevice.exceptions.DDSError(0): Attempted to use invalid DDS bus
Traceback (most recent call last):
  File "/home/rabi/anaconda3/envs/artiq-2016-04-13/lib/python3.5/site-packages/artiq/master/worker_impl.py", line 231, in main
    exp_inst.run()
  File "/home/rabi/anaconda3/envs/artiq-2016-04-13/lib/python3.5/site-packages/artiq/language/core.py", line 192, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
  File "/home/rabi/anaconda3/envs/artiq-2016-04-13/lib/python3.5/site-packages/artiq/coredevice/core.py", line 108, in run
    self.comm.serve(object_map, symbolizer)
  File "/home/rabi/anaconda3/envs/artiq-2016-04-13/lib/python3.5/site-packages/artiq/coredevice/comm_generic.py", line 527, in serve
    self._serve_exception(object_map, symbolizer)
  File "/home/rabi/anaconda3/envs/artiq-2016-04-13/lib/python3.5/site-packages/artiq/coredevice/comm_generic.py", line 519, in _serve_exception
    raise python_exn
artiq.coredevice.exceptions.DDSError: Attempted to use invalid DDS bus
ERROR:master:artiq.master.scheduler:got worker exception in run stage, deleting RID 3084

If I correct the bus channel the experiment runs but I get the OSError on both systems as in #393.

sbourdeauducq commented 8 years ago

If your bitstream is built from master, please use the dev packages for the software as well.

sbourdeauducq commented 8 years ago

Or better, build the bitstream from release-1.

whitequark commented 8 years ago

That probably won't help, that code didn't change since branching... But yes.

r-srinivas commented 8 years ago

So I can just install artiq from artiq-dev/artiq with python3.5 setup.py develop --user from the manual?

I tried that on the virtual machine and can get artiq_master running but artiq_gui gives me

rabi@68810MAGTRAPVM:~/artiq-dev/artiq$ artiq_gui
Traceback (most recent call last):
  File "/home/rabi/.local/bin/artiq_gui", line 9, in <module>
    load_entry_point('artiq', 'console_scripts', 'artiq_gui')()
  File "/home/rabi/anaconda3/lib/python3.5/site-packages/setuptools-20.2.2-py3.5.egg/pkg_resources/__init__.py", line 549, in load_entry_point
  File "/home/rabi/anaconda3/lib/python3.5/site-packages/setuptools-20.2.2-py3.5.egg/pkg_resources/__init__.py", line 2541, in load_entry_point
ImportError: Entry point ('console_scripts', 'artiq_gui') not found
r-srinivas commented 8 years ago

conda list

rabi@68810MAGTRAPVM:~/artiq-dev/artiq$ conda list
# packages in environment at /home/rabi/anaconda3:
#
_license                  1.1                      py35_1    defaults
abstract-rendering        0.5.1               np110py35_0    defaults
aiohttp                   0.21.2                    <pip>
alabaster                 0.7.7                    py35_0    defaults
anaconda                  2.4.1               np110py35_0    defaults
anaconda-client           1.3.1                    py35_0    defaults
argcomplete               1.0.0                    py35_1    defaults
artiq (/home/rabi/artiq-dev/artiq) 1.0rc1+204.gfaa268e           <pip>
astropy                   1.1.2               np110py35_0    defaults
asyncserial               0.1             py_3+gitc51e345    http://conda.anaconda.org/m-labs/channel/main/noarch/asyncserial-0.1-py_3+gitc51e345.tar.bz2
babel                     2.2.0                    py35_0    defaults
beautifulsoup4            4.4.1                    py35_0    defaults
bitarray                  0.8.1                    py35_0    defaults
blaze                     0.9.0                     <pip>
blaze-core                0.9.0                    py35_0    defaults
bokeh                     0.11.1                   py35_0    defaults
boto                      2.39.0                   py35_0    defaults
bottleneck                1.0.0               np110py35_0    defaults
cffi                      1.5.2                    py35_0    defaults
chardet                   2.3.0                     <pip>
clyent                    1.2.1                    py35_0    defaults
colorama                  0.3.6                    py35_0    defaults
conda                     4.0.5                    py35_0    defaults
conda-build               1.19.2                   py35_0    defaults
conda-env                 2.4.5                    py35_0    defaults
configobj                 5.0.6                    py35_0    defaults
cryptography              1.2.3                    py35_0    defaults
curl                      7.45.0                        0    defaults
cycler                    0.10.0                   py35_0    defaults
cython                    0.23.4                   py35_0    defaults
cytoolz                   0.7.5                    py35_0    defaults
datashape                 0.5.1                    py35_0    defaults
decorator                 4.0.9                    py35_0    defaults
docutils                  0.12                     py35_0    defaults
dynd                      f641248                   <pip>
dynd-python               0.7.1                    py35_0    defaults
et-xmlfile                1.0.1                     <pip>
et_xmlfile                1.0.1                    py35_0    defaults
fastcache                 1.0.2                    py35_0    defaults
flask                     0.10.1                   py35_1    defaults
fontconfig                2.11.1                        5    defaults
freetype                  2.5.5                         0    defaults
greenlet                  0.4.9                    py35_0    defaults
h5py                      2.5.0               np110py35_4    defaults
hdf5                      1.8.15.1                      2    defaults
idna                      2.0                      py35_0    defaults
ipykernel                 4.3.1                    py35_0    defaults
ipython                   4.1.2                    py35_0    defaults
ipython-genutils          0.1.0                     <pip>
ipython-notebook          4.0.4                    py35_0    defaults
ipython-qtconsole         4.0.1                    py35_0    defaults
ipython_genutils          0.1.0                    py35_0    defaults
ipywidgets                4.1.1                    py35_0    defaults
itsdangerous              0.24                     py35_0    defaults
jbig                      2.1                           0    defaults
jdcal                     1.2                      py35_0    defaults
jedi                      0.9.0                    py35_0    defaults
jinja2                    2.8                      py35_0    defaults
jpeg                      8d                            0    defaults
jsonschema                2.4.0                    py35_0    defaults
jupyter                   1.0.0                    py35_1    defaults
jupyter-client            4.2.1                     <pip>
jupyter-console           4.1.1                     <pip>
jupyter-core              4.1.0                     <pip>
jupyter_client            4.2.1                    py35_0    defaults
jupyter_console           4.1.1                    py35_0    defaults
jupyter_core              4.1.0                    py35_0    defaults
libdynd                   0.7.1                         0    defaults
libffi                    3.0.13                        0    defaults
libgfortran               3.0                           0    defaults
libgit2                   0.22.3                        2    http://conda.anaconda.org/m-labs/channel/main/linux-64/libgit2-0.22.3-2.tar.bz2
libpng                    1.6.17                        0    defaults
libsodium                 1.0.3                         0    defaults
libssh2                   1.6.0                         2    http://conda.anaconda.org/m-labs/channel/main/linux-64/libssh2-1.6.0-2.tar.bz2
libtiff                   4.0.6                         1    defaults
libxml2                   2.9.2                         0    defaults
libxslt                   1.1.28                        0    defaults
lit                       0.4.1                     <pip>
llvmlite                  0.9.0                    py35_0    defaults
llvmlite-artiq            0.5.1                   py35_12    http://conda.anaconda.org/m-labs/channel/main/linux-64/llvmlite-artiq-0.5.1-py35_12.tar.bz2
lxml                      3.5.0                    py35_0    defaults
markupsafe                0.23                     py35_0    defaults
matplotlib                1.5.1               np110py35_0    defaults
migen (/home/rabi/artiq-dev/migen) 0.2                       <pip>
misoc (/home/rabi/artiq-dev/misoc) 0.1                       <pip>
mistune                   0.7.2                    py35_0    defaults
mkl                       11.3.1                        0    defaults
mpmath                    0.19                     py35_0    defaults
multipledispatch          0.4.8                    py35_0    defaults
nbconvert                 4.1.0                    py35_0    defaults
nbformat                  4.0.1                    py35_0    defaults
networkx                  1.11                     py35_0    defaults
nltk                      3.2                      py35_0    defaults
nose                      1.3.7                    py35_0    defaults
notebook                  4.1.0                    py35_1    defaults
numba                     0.24.0              np110py35_0    defaults
numexpr                   2.4.6               np110py35_1    defaults
numpy                     1.10.4                   py35_1    defaults
odo                       0.4.2                    py35_0    defaults
openblas                  0.2.14                        4    defaults
openpyxl                  2.3.2                    py35_0    defaults
openssl                   1.0.2g                        0    defaults
outputcheck               0.4.1                     <pip>
pandas                    0.18.0              np110py35_0    defaults
patchelf                  0.8                           0    defaults
path.py                   8.1.2                    py35_1    defaults
patsy                     0.4.0               np110py35_0    defaults
pep8                      1.7.0                    py35_0    defaults
pexpect                   3.3                      py35_0    defaults
pickleshare               0.5                      py35_0    defaults
pillow                    3.1.1                    py35_0    defaults
pip                       8.1.1                    py35_1    defaults
ply                       3.8                      py35_0    defaults
prettytable               0.7.2                     <pip>
psutil                    4.1.0                    py35_0    defaults
ptyprocess                0.5                      py35_0    defaults
py                        1.4.31                   py35_0    defaults
pyasn1                    0.1.9                    py35_0    defaults
pycosat                   0.6.1                    py35_0    defaults
pycparser                 2.14                     py35_0    defaults
pycrypto                  2.6.1                    py35_0    defaults
pycurl                    7.19.5.3                 py35_0    defaults
pyflakes                  1.1.0                    py35_0    defaults
pygit2                    0.22.1                   py35_2    http://conda.anaconda.org/m-labs/channel/main/linux-64/pygit2-0.22.1-py35_2.tar.bz2
pygments                  2.1.1                    py35_0    defaults
pyopenssl                 0.15.1                   py35_1    defaults
pyparsing                 2.0.3                    py35_0    defaults
pyqt                      4.11.4                   py35_1    defaults
pyqtgraph-pyqtgraph-0.9.10-106 g6e837fa                  <pip>
pyserial                  2.7                      py35_0    defaults
pytables                  3.2.2               np110py35_0    defaults
pytest                    2.8.5                    py35_0    defaults
python                    3.5.1                         0    defaults
python-dateutil           2.5.0                    py35_0    defaults
python-levenshtein        0.12.0                    <pip>
pythonparser              0.0                        py_5    http://conda.anaconda.org/m-labs/channel/main/noarch/pythonparser-0.0-py_5.tar.bz2
pytz                      2016.1                   py35_0    defaults
pyyaml                    3.11                     py35_1    defaults
pyzmq                     15.2.0                   py35_0    defaults
qt                        4.8.7                         1    defaults
qtconsole                 4.1.1                    py35_1    defaults
quamash                   0.5.4                     <pip>
readline                  6.2                           2    defaults
redis                     2.6.9                         0    defaults
redis-py                  2.10.3                   py35_0    defaults
regex                     2015.11.22               py35_1    http://conda.anaconda.org/m-labs/channel/main/linux-64/regex-2015.11.22-py35_1.tar.bz2
requests                  2.9.1                    py35_0    defaults
rope                      0.9.4                    py35_1    defaults
rope-py3k                 0.9.4.post1               <pip>
scikit-image              0.12.3              np110py35_0    defaults
scikit-learn              0.17.1              np110py35_0    defaults
scipy                     0.17.0              np110py35_2    defaults
setuptools                20.2.2                   py35_0    defaults
simplegeneric             0.8.1                    py35_0    defaults
sip                       4.16.9                   py35_0    defaults
six                       1.10.0                   py35_0    defaults
snowballstemmer           1.2.1                    py35_0    defaults
sockjs-tornado            1.0.1                    py35_0    defaults
sphinx                    1.3.5                    py35_0    defaults
sphinx-argparse           0.1.15                    <pip>
sphinx-rtd-theme          0.1.9                     <pip>
sphinx_rtd_theme          0.1.9                    py35_0    defaults
spyder                    2.3.8                    py35_1    defaults
spyder-app                2.3.8                    py35_0    defaults
sqlalchemy                1.0.12                   py35_0    defaults
sqlite                    3.9.2                         0    defaults
statsmodels               0.6.1               np110py35_0    defaults
sympy                     1.0                      py35_0    defaults
system                    5.8                           2    defaults
tables                    3.2.2                     <pip>
terminado                 0.5                      py35_1    defaults
theano                    0.7.0               np110py35_0    defaults
tk                        8.5.18                        0    defaults
toolz                     0.7.4                    py35_0    defaults
tornado                   4.3                      py35_0    defaults
traitlets                 4.1.0                    py35_0    defaults
ujson                     1.35                     py35_0    defaults
unicodecsv                0.14.1                   py35_0    defaults
util-linux                2.21                          0    defaults
werkzeug                  0.11.4                   py35_0    defaults
wheel                     0.29.0                   py35_0    defaults
xlrd                      0.9.4                    py35_0    defaults
xlsxwriter                0.8.4                    py35_0    defaults
xlwt                      1.0.0                    py35_0    defaults
xz                        5.0.5                         1    defaults
yaml                      0.1.6                         0    defaults
zeromq                    4.1.3                         0    defaults
zlib                      1.2.8                         0    defaults
rabi@68810MAGTRAPVM:~/artiq-dev/artiq$ 
sbourdeauducq commented 8 years ago

I meant the dev conda channel (which tracks master) but it's probably better that you build the bitstream from release-1 instead.

sbourdeauducq commented 8 years ago

https://github.com/m-labs/artiq/tree/release-1

sbourdeauducq commented 8 years ago

Reproduced when mixing gateware 1.x and software 2.x. Please don't do that (this is why it gives you a warning).

whitequark commented 8 years ago

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 324: invalid continuation byte

But why is it doing this? I don't think it should.

sbourdeauducq commented 8 years ago

If that helps, the string that fails decoding is:

b'0x00001747\nartiq.coredevice.dds._DDSGeneric.set_mu\nC:\\Anaconda64\\envs\\stable\\lib\\site-packages\\artiq\\coredevice/dds.py:179\n0x00001377\nartiq.coredevice.dds._DDSGeneric.set\nC:\\Anaconda64\\envs\\stable\\lib\\site-packages\\artiq\\coredevice/dds.py:186\n0x00001de7\nartiq_run_repository\\coredevice_examples\\simple\xdds_test.DDSTest.run\nrepository\\coredevice_examples\\simple/dds_test.py:32\n0x00001093\n__modinit__\n<synthesized>:1\n'

The problem is fully reproducible.

sbourdeauducq commented 8 years ago

May be a bug with the old (1.0rc2) compiler and not due to mixing.

sbourdeauducq commented 8 years ago

With master, the string is:

b'0x00000dd3\n__modinit__\nC:\\Anaconda64\\envs\\python\\lib\\site-packages\\artiq\\coredevice/dds.py:189\nartiq.coredevice.dds._DDSGeneric.set\nC:\\Anaconda64\\envs\\python\\lib\\site-packages\\artiq\\coredevice/dds.py:196\nartiq_run_repository\\coredevice_examples\\simple\\dds_test.DDSTest.run\nrepository\\coredevice_examples\\simple/dds_test.py:32\n__modinit__\n<synthesized>:1\n'
whitequark commented 8 years ago

Looks like the problem is here: artiq_run_repository\\coredevice_examples\\simple\xdds_test.DDSTest.run. See that \x? Looks like some kind of very stupid escaping failure.

r-srinivas commented 8 years ago

I don't think it's a mixing issue. I get the same error with the software and gateware from 2016-04-04.

With the wrong dds bus channel I get the following error message.

C:\Anaconda3\artiq_test>call activate artiq-2016-04-04
Deactivating environment "C:\Anaconda3"...
Activating environment "C:\Anaconda3\envs\artiq-2016-04-04"...
ERROR:worker(1209,dds_start.py):root:Terminating with exception (UnicodeDecodeEr
ror: 'utf-8' codec can't decode byte 0xdd in position 324: invalid continuation
byte)
Traceback (most recent call last):
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\master\worker
_impl.py", line 231, in main
    exp_inst.run()
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\language\core
.py", line 192, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
re.py", line 108, in run
    self.comm.serve(object_map, symbolizer)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
mm_generic.py", line 527, in serve
    self._serve_exception(object_map, symbolizer)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
mm_generic.py", line 508, in _serve_exception
    traceback = list(reversed(symbolizer(backtrace))) + \
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\coredevice\co
re.py", line 89, in <lambda>
    lambda addresses: target.symbolize(library, addresses)
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\compiler\targ
ets.py", line 166, in symbolize
    library=library) \
  File "C:\Anaconda3\envs\artiq-2016-04-04\lib\site-packages\artiq\compiler\targ
ets.py", line 39, in __enter__
    tempfiles["__stdout__"] = stdout.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 324: invali
d continuation byte
ERROR:master:artiq.master.scheduler:got worker exception in run stage, deleting
RID 1209

Also seems to happen with the software and gateware updated 04-15.

sbourdeauducq commented 8 years ago

with the software and gateware updated 04-15.

From main or dev? What is the output of python -c "import artiq; print(artiq.__version__)"?

r-srinivas commented 8 years ago

From main.


C:\Anaconda3\artiq_test>call activate artiq-2016-04-15
Deactivating environment "C:\Anaconda3"...
Activating environment "C:\Anaconda3\envs\artiq-2016-04-15"...
[artiq-2016-04-15] C:\Anaconda3\artiq_test>python -c "import artiq; print(artiq.
__version__)"
1.0rc2
sbourdeauducq commented 8 years ago

Yes, the problem is in 1.0rc2, and is fixed in git.