Repository navigation
Closed
Description
This fails on python 2.7.14, dask 0.20.1, but works on dask 0.19.4.
As far as I can tell, a task like (operator.mul, 0j, [np.ndarray(...)]) gets constructed by subgraph_callable which produces the TypeError: can't multiply sequence by non-int of type 'complex' exception below
from __future__ import print_function
import dask.array as da
import numpy as np
row_chunks = (25, 25, 25, 25)
chan_chunks = (4, 4, 4, 4)
corr1_chunks = (2,)
corr2_chunks = (2,)
rows = sum(row_chunks)
chans = sum(chan_chunks)
corr1 = sum(corr1_chunks)
corr2 = sum(corr2_chunks)
shape = (rows, chans, corr1, corr2)
chunks = (row_chunks, chan_chunks, corr1_chunks, corr2_chunks)
vis = (da.random.random(shape, chunks=chunks) +
da.random.random(shape, chunks=chunks)*1j)
def _grid2(vis):
vis = vis[0][0]
return np.ones(vis.shape[:2], dtype=vis.dtype)
grid2 = da.core.atop(_grid2, ("row", "chan"),
vis, ("row", "chan", "corr1", "corr2"),
dtype=vis.dtype)
print(grid2.compute().shape)Produces the following:
Traceback (most recent call last):
File "dask_atop_issue.py", line 38, in <module>
print(grid.compute().shape)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/base.py", line 156, in compute
(result,) = compute(self, traverse=False, **kwargs)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/base.py", line 397, in compute
results = schedule(dsk, keys, **kwargs)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/threaded.py", line 76, in get
pack_exception=pack_exception, **kwargs)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/local.py", line 501, in get_async
raise_exception(exc, tb)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/local.py", line 272, in execute_task
result = _execute_task(task, data)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/local.py", line 253, in _execute_task
return func(*args2)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/optimization.py", line 942, in __call__
dict(zip(self.inkeys, args)))
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 132, in _get_recursive
res = cache[x] = _get_recursive(dsk, dsk[x], cache)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 136, in _get_recursive
args2 = [_get_recursive(dsk, k, cache) for k in args]
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 126, in _get_recursive
return [_get_recursive(dsk, k, cache) for k in x]
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 132, in _get_recursive
res = cache[x] = _get_recursive(dsk, dsk[x], cache)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 136, in _get_recursive
args2 = [_get_recursive(dsk, k, cache) for k in args]
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 132, in _get_recursive
res = cache[x] = _get_recursive(dsk, dsk[x], cache)
File "/home/sperkins/tmp/python/dask/venv/local/lib/python2.7/site-packages/dask/core.py", line 137, in _get_recursive
return func(*args2)
TypeError: can't multiply sequence by non-int of type 'complex'
Metadata
Metadata
Assignees
Labels
No labels
Activity
mrocklin commentedon Nov 12, 2018
sjperkins commentedon Nov 12, 2018
@mrocklin I've reduced the example further.
concatenate=Truedoes indeed ameliorate this issue, but its preferable not to rely on this for performance reasons. Unfortunately I don't have time to delve deep into the new dask internals.mrocklin commentedon Nov 12, 2018
Here is a perhaps even simpler failure that shows the problem you're running into
You are missing dimensions in your output, so they get concatenated into a list of elements. If you want to treat that list as a numpy array then you should pass
concatenate=True. Really the question here is why this would have worked before.I'm curious, how is passing
concatenate=Truea performance issue for you?sjperkins commentedon Nov 12, 2018
Correct this is a mistake in my updated example, I've re-updated it, and the complex multiplied by list issue still occurs.
I use this style based on @shoyer's comments in #3412 (comment)
mrocklin commentedon Nov 12, 2018
Hrm, interesting, I've reduced this to the following minimal example
Yeah, looks like a genuine bug. My guess is that this comes up in the atop fusion code, my guess is somewhere around here:
dask/dask/array/top.py
Lines 599 to 617 in df4c6dc
If anyone has time to take a look that would be welcome. I'm busy the next couple days.
Avoid fusing dependencies of atop reductions
Avoid fusing dependencies of atop reductions (#4207)