-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong shape after indexing a single element with a slice #754
Comments
Additionally, consider the following code (using the current master branch): import heat as ht
mask3D = ht.random.randn(2,2,2, split=0)
print('before where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', mask3D[0].gshape, 'lshape:', mask3D[0].lshape, 'split:', mask3D[0].split, flush=True); ht.MPI_WORLD.Barrier() # organize output
mask2D = ht.where(mask3D[0] > 0, 1., 0.)
print(' after where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', mask2D.gshape, 'lshape:', mask2D.lshape, 'split:', mask2D.split, flush=True) With one process, this results in:
With two processes:
My guess is that because of the lshape |
unfortunately, some things from traditional python dont translate into heat. in the additional example there, the issue comes from the slicing ( when slicing a distributed object along the dimension which it is distributed (i.e. slicing on dimension 0 with split == 0) the result is not balanced between the processes. to correct this, all one needs to do is call the import heat as ht
mask3D = ht.random.randn(2,2,2, split=0)
print('before where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', mask3D[0].gshape, 'lshape:', mask3D[0].lshape, 'split:', mask3D[0].split, flush=True); ht.MPI_WORLD.Barrier() # organize output
sliced = mask3D[0]
sliced.balance_()
mask2D = ht.where(sliced > 0, 1., 0.)
print(' after where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', mask2D.gshape, 'lshape:', mask2D.lshape, 'split:', mask2D.split, flush=True) an in-line (out of place) balance function is in the works as well as for the main body of this issue, this requires more searching. it appears to be a difference in the shape of single element arrays and their defined shape. |
Hi, thanks for your reply! Balancing sounds great, however do you also recommend it for the case of setting one layer: import heat as ht
something3D = ht.zeros((2,2,2), split=0)
mask3D = ht.random.randn(2,2,2, split=0)
print('before where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', mask3D[0].gshape, 'lshape:', mask3D[0].lshape, 'split:', mask3D[0].split, flush=True); ht.MPI_WORLD.Barrier() # organize output
something3D[0] = ht.where(mask3D[0] > 0, 1., 0.)
print(' after where |', 'rank:', ht.MPI_WORLD.rank, 'gshape:', something3D.gshape, 'lshape:', something3D.lshape, 'split:', something3D.split, flush=True) Of course, splitting along a different dimension than the one I'm slicing would be best solution. Unfortunately I have to slice along every dimension eventually. Currently I'm using: something3D[0] = ht.where(mask3D > 0, 1., 0.)[0] Which I think is still faster than balancing and redistributing or resplitting. |
@ben-bou could you try out this branch and see if you get what you expect out of parallel slicing?
|
Description
As seen in the code below, after a __getitem__ that pulls only one element from one process and leaves the other processes empty, the gshape is wrong.
To Reproduce
Steps to reproduce the behavior:
__getitem__
one process has one element, the other process is empty.
wrong
gshape
andlshape
Illustrative
Run with one process, the output is as expected:
Run with 2 processes:
The gshape has only one dimension, but should have two because a
slice
was used for indexing. The lshape of rank 1 should also have two dimensions (#656).Expected behavior
A clear and concise description of what you expected to happen.
See above.
Version Info
0.5.1; also on master branch
Additional comments
Any other comments here.
The text was updated successfully, but these errors were encountered: