You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [50]: einsum('ki,jk->ij', da.from_array(a, 2), da.from_array(b, 2)).compute()
Out[50]:
array([[10, 28, 46, 64],
[13, 40, 67, 94]])
In [51]: np.einsum('ki,jk->j', a, b)
Out[52]: array([ 23, 68, 113, 158])
In [52]: einsum('ki,jk->j', da.from_array(a, 2), da.from_array(b, 2)).compute()
ValueError: einstein sum subscripts string contains too many subscripts for operand 0
Nope, this is as far as I got. I would encourage you to try finishing it up if you're interested. I think we just need some sort of recursion inside the kernel function to handle nested arguments.
I maybe misunderstanding the technology, but couldn't dask array integration with the elemental distributed computation library give us for free a lot of these use cases? Or maybe they can be easily rewritten in ufora( which seems to be getting numpy support anyway).
Why spend the maintenance and time to rengineer these methods?
Integration with a foreign library is likely more costly than implementing einsum, which I anticipate can be done in 10-20 lines of code.
However, your general theme of "why make an array library when others already exist" has general merit. People probably reinvent wheels because existing wheels don't do exactly what they want. Elemental itself is a reinvention on top of of several other systems. A lot of novelty comes with a lot of redundancy.
If all anyone wanted was einsum, I agree. However the upfront cost of integrating elemental will be amortized over all the future use cases and feature requests that it will fulfill, including those that are novel enough to be triggered. This along with speed and maintenance benefits seems compelling to me.
To your second point, I don't think it would replace dask, but leverage it (I could be wrong). To keep dask light, it could be an option dependancy.
I think enabling the sorts of out of core algorithms that elemental would facilitate can be useful for modeling pocket data. (On a single machine or only multiple node?)
Suggestions are always welcome. I am aware of and have great respect for Elemental. At the moment I don't see a way to integrate the two systems, nor do I know of concrete use cases where access to both systems would be very valuable (usually one or the other will do) and so I don't plan to spend my personal time on it, though I would encourage others to look into it and report back. Internally the two systems work very differently.
I suggest that we continue this conversation on another issue rather than this one, which is mostly about implementing einsum within dask.array.
@mrocklin i had initially needed einsum for an application, but ended up solving the specific problem with a more naive approach. in spite of that, i did get a chance to work towards solving the problem, but got wrapped up in other things and thus wasn't able to bring it to completion.
in general, i am somewhat interested in contributing to the project. if this is still something that needs doing i'd be happy to take another swing. any suggestions for other ways to contribute would also be welcome.
Submit is for sending individual python functions on python objects. If you're already using dask collections like dask.array then you probably want to stick to compute and persist.
But really you don't need dask.distributed for this at all, I would consider using the default single threaded scheduler until you need the features of the distributed scheduler:
This was just a simple example for testing it out - for most cases we will be using 4 index tensors that will be much larger (~100 GB up to 1 TB).
I'm instead getting an error now (using your 2nd case above without the client for now):
Traceback (most recent call last):
File "mp2.py", line 28, in <module>
y = y.compute()
File "/Library/Python/2.7/site-packages/dask/base.py", line 86, in compute
return compute(self, **kwargs)[0]
File "/Library/Python/2.7/site-packages/dask/base.py", line 179, in compute
results = get(dsk, keys, **kwargs)
File "/Library/Python/2.7/site-packages/dask/threaded.py", line 58, in get
**kwargs)
File "/Library/Python/2.7/site-packages/dask/async.py", line 481, in get_async
raise(remote_exception(res, tb))
dask.async.TypeError: 'concatenate' is an invalid keyword for einsum
Thank you guys for the help! I apologize if it seems like I'm not doing too much work here in hunting down errors - my group is testing out software packages that might suit our needs in scaling up our codes without having to worry anymore about the nitty-gritty details of task-scheduling. Also, I figure you guys can do in 2 minutes what would take me 2+ hours to find out. :)
I regret not having had time to create a full PR for this. If it helps anyone though here is the implementation I have been running with for some time now; iirc it fixes a couple bugs vs my previous comment and also handles casting better.
I don't know if it performs well in all cases but it has been working well for my application. I think the only thing missing besides tests and so forth is to merge in support for the string 'ij,jm->im'-style subscripts.
Activity
shoyer commentedon Sep 19, 2015
This version appears to work:
So this looks like a partial solution:
But it fails for some variants of einsum:
matthewwillian commentedon Oct 11, 2015
Has any progress been made on implementing this ?
shoyer commentedon Oct 11, 2015
Nope, this is as far as I got. I would encourage you to try finishing it up if you're interested. I think we just need some sort of recursion inside the kernel function to handle nested arguments.
matthewwillian commentedon Oct 11, 2015
Cool. I will take a look.
mrocklin commentedon Nov 9, 2015
@matthewwillian did you need
einsumfor an application or were you looking to get in to development?datnamer commentedon Nov 11, 2015
I maybe misunderstanding the technology, but couldn't dask array integration with the elemental distributed computation library give us for free a lot of these use cases? Or maybe they can be easily rewritten in ufora( which seems to be getting numpy support anyway).
Why spend the maintenance and time to rengineer these methods?
mrocklin commentedon Nov 11, 2015
Integration with a foreign library is likely more costly than implementing einsum, which I anticipate can be done in 10-20 lines of code.
However, your general theme of "why make an array library when others already exist" has general merit. People probably reinvent wheels because existing wheels don't do exactly what they want. Elemental itself is a reinvention on top of of several other systems. A lot of novelty comes with a lot of redundancy.
datnamer commentedon Nov 11, 2015
If all anyone wanted was einsum, I agree. However the upfront cost of integrating elemental will be amortized over all the future use cases and feature requests that it will fulfill, including those that are novel enough to be triggered. This along with speed and maintenance benefits seems compelling to me.
To your second point, I don't think it would replace dask, but leverage it (I could be wrong). To keep dask light, it could be an option dependancy.
I think enabling the sorts of out of core algorithms that elemental would facilitate can be useful for modeling pocket data. (On a single machine or only multiple node?)
mrocklin commentedon Nov 11, 2015
If this is something you're interested in working on that would be great!
datnamer commentedon Nov 11, 2015
Maybe at some point. Right now I just wanted to make what I thought was a helpful suggestion :)
mrocklin commentedon Nov 11, 2015
Suggestions are always welcome. I am aware of and have great respect for Elemental. At the moment I don't see a way to integrate the two systems, nor do I know of concrete use cases where access to both systems would be very valuable (usually one or the other will do) and so I don't plan to spend my personal time on it, though I would encourage others to look into it and report back. Internally the two systems work very differently.
I suggest that we continue this conversation on another issue rather than this one, which is mostly about implementing
einsumwithin dask.array.datnamer commentedon Nov 11, 2015
Ah ok. Didn't realize they were fundamentally incompatible. Sorry for the noise
matthewwillian commentedon Nov 12, 2015
@mrocklin i had initially needed einsum for an application, but ended up solving the specific problem with a more naive approach. in spite of that, i did get a chance to work towards solving the problem, but got wrapped up in other things and thus wasn't able to bring it to completion.
in general, i am somewhat interested in contributing to the project. if this is still something that needs doing i'd be happy to take another swing. any suggestions for other ways to contribute would also be welcome.
shoyer commentedon Oct 5, 2016
With the new
concatenate=Trueargument toatop, this version seems to work:jdmcclain47 commentedon Oct 6, 2016
I was using this simple-ish code on my desktop and got the exception "Client not running".
mrocklin commentedon Oct 6, 2016
Submit is for sending individual python functions on python objects. If you're already using dask collections like dask.array then you probably want to stick to compute and persist.
But really you don't need dask.distributed for this at all, I would consider using the default single threaded scheduler until you need the features of the distributed scheduler:
jdmcclain47 commentedon Oct 6, 2016
This was just a simple example for testing it out - for most cases we will be using 4 index tensors that will be much larger (~100 GB up to 1 TB).
I'm instead getting an error now (using your 2nd case above without the client for now):
Thank you guys for the help! I apologize if it seems like I'm not doing too much work here in hunting down errors - my group is testing out software packages that might suit our needs in scaling up our codes without having to worry anymore about the nitty-gritty details of task-scheduling. Also, I figure you guys can do in 2 minutes what would take me 2+ hours to find out. :)
TomAugspurger commentedon Oct 6, 2016
@jdmcclain47 you'll need to grab a recent copy of dask off github. The
concatenate=Truekeyword was added in #1609 a couple days ago.jdmcclain47 commentedon Oct 6, 2016
ah thanks, works like a charm!
mrocklin commentedon Oct 6, 2016
@shoyer any desire to open a PR with
einsum? Seems like it has found some use before even being in the repository :)In the future we might consider breaking this into two
atopcalls to reduce the data a bit per-chunk before moving it and concatenating.chrisbarber commentedon Jan 16, 2017
A slight modification to support the
einsum(op0, sublist0, op1, sublist1, ..., [sublistout])variant:chrisbarber commentedon Jan 18, 2017
This version is parallelizable along the contracted axes and avoids concatenation:
mrocklin commentedon Jan 18, 2017
Any interest in opening a full PR @chrisbarber ? Would love to have you as a contributor.
GuillaumeLeclerc commentedon Mar 2, 2018
This feature would be very useful 😄
chrisbarber commentedon Mar 2, 2018
I regret not having had time to create a full PR for this. If it helps anyone though here is the implementation I have been running with for some time now; iirc it fixes a couple bugs vs my previous comment and also handles casting better.
I don't know if it performs well in all cases but it has been working well for my application. I think the only thing missing besides tests and so forth is to merge in support for the string
'ij,jm->im'-style subscripts.mrocklin commentedon Mar 23, 2018
Here is an interesting implementation of einsum that seems to support dask array: https://github.com/dgasmith/opt_einsum
jakirkham commentedon Apr 19, 2018
Solved in PR ( #3412 ) thanks to @sjperkins.
Rename backend in shuffle to method (dask#732)