Pysyft: N-ary methods/iterable methods do not work remotely

Created on 10 Jul 2018  路  5Comments  路  Source: OpenMined/PySyft

Issue Template

Context

User Story:

When iterable methods are called on remote objects, the get() method returns an empty tensor. See expected and current behavior for more info.

torch.stack and torch.cat are great examples of such methods.
torch.stack
torch.cat

Expected Behavior

>>> x = torch.FloatTensor([1,2,3,4]).send(remote)
>>> y = torch.FloatTensor([3,4,1,2]).send(remote)
>>> z = torch.FloatTensor([5,2,1,4]).send(remote)
>>> torch.stack([x,y,z]).get()

 1  2  3  4
 3  4  1  2
 5  2  1  4
[torch.FloatTensor of size 3x4]

Current Behavior

What is the current behavior?

>>> x = torch.FloatTensor([1,2,3,4]).send(remote)
>>> y = torch.FloatTensor([3,4,1,2]).send(remote)
>>> z = torch.FloatTensor([5,2,1,4]).send(remote)
>>> torch.stack([x,y,z]).get()
[torch.FloatTensor with no dimension]

Failure Information (for bugs)

When iterable methods are called on remote objects, the get() method returns an empty tensor.

Steps to Reproduce (for bugs)

Please provide detailed steps for reproducing the issue. (for bugs)

>>> x = torch.FloatTensor([1,2,3,4]).send(remote)
>>> y = torch.FloatTensor([3,4,1,2]).send(remote)
>>> z = torch.FloatTensor([5,2,1,4]).send(remote)
>>> torch.stack([x,y,z]).get()

Most helpful comment

Yes, my PR fix this, I will add a unit test

All 5 comments

For such methods, arrays are not supported as an argument and a tensor of tensors should be only used.

Hey @alhparsa, I'm reopening this. Maintaining the original semantics of PyTorch is very important, and I think this should be covered when #1395 lands. We'll close when that happens.

Yes, my PR fix this, I will add a unit test

doing this works for stack and cat
torch.stack([x.get(),y.get(),z.get()])

1 2 3
2 3 4
5 6 7
[torch.FloatTensor of size 3x3]

I added the unittests based on this.

This also works!

t = torch.FloatTensor([x,y,z])
torch.stack(t).get()

@bartimaeus12 your code actually doesn't apply the function remotely. What it does is that it gets the tensors and then it applies the function locally on them. What we want is something like torch.stack(some array of arrays or a tensor of tensors).get() this way the function is applied remotely first and then by calling the get() method we receive the data.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alberduris picture alberduris  路  3Comments

mgale694 picture mgale694  路  3Comments

akirahirohito picture akirahirohito  路  3Comments

iamtrask picture iamtrask  路  4Comments

swaroopch picture swaroopch  路  4Comments