dask.array.jit or dask.array.vectorize
See original GitHub issueWhen working with dask-glm I find myself interacting with functions like the following (where x
is a dask.array):
def l2(x, t):
return 1 / (1 + lamda * t) * x
def l1(x, t):
return (absolute(x) > lamda * t) * (x - sign(x) * lamda * t)
These are costly in a few ways:
- They have decent overhead, because they repeatedly regenerate relatively large graphs
- On computation, even if we fuse, we create many intermediate copies of numpy arrays
So there are two part solutions that we could combine here:
- For any given dtype/shape/chunks signature, we could precompute a dask graph. When the same dtype/shape/chunks signature comes in we would stitch the new keys in at the right place, change around some tokenized values, and ship the result out without calling all of the dask.array code.
- We could numba.jit fused tasks
Using numba would actually be pretty valuable in some cases in dask-glm. This could be an optimization at the task graph level. I suspect that if we get good at recognizing recurring patterns and cache well that we could make this fast-ish. (add, _, (mul, _, _)) -> numba.jit(lambda x, y, z: x + y * z)
. We might also be able to back out patterns based on keys (not sure if this is safe)
Issue Analytics
- State:
- Created 7 years ago
- Comments:27 (23 by maintainers)
Top Results From Across the Web
dask.array.gufunc.apply_gufunc
Function to call like func(*args, **kwargs) on input arrays ( *args ) that returns an array or tuple of arrays.
Read more >Stencil Computations with Numba
Many array computing functions operate only on a local region of the array. ... But if we JIT compile this function with Numba,...
Read more >Array
Dask Array implements a subset of the NumPy ndarray interface using blocked algorithms, cutting up the large array into many small arrays.
Read more >Create Dask Arrays
You can load or store Dask arrays from a variety of common sources like HDF5, NetCDF, Zarr, or any format that supports NumPy-style...
Read more >dask.array.Array
dask.array.Array¶ ... A parallel nd-array comprised of many numpy arrays arranged in a grid. This constructor is for advanced uses only. For normal...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For what it’s worth, I would expect
dask.array.vectorize
to be a dask friendly version ofnumpy.vectorize
that doesn’t require numba. Numba support would also be handy but I would save that variant for another function name (e.g.,numba_vectorize
) or a keyword argument (numba=True
).This will likely be handled by the current effort on high level expression graphs. Closing.