Pysyft: Promise and PromiseTensor

Created on 15 Aug 2019  路  8Comments  路  Source: OpenMined/PySyft

In this issue, I will be creating a new tensor type called PromiseTensor. This Issue will be updated to reflect what I intend to build as I am working on it.

This will allow one worker to:

1) tell another worker that it will receive a tensor with a certain id in the future.

x = th.tensor([1,2,3,4]).promise() # initialize a promise
x_promise = sy.PromiseTensor() # alternative promise initialization
ptr_to_x_promise = x_promise.send(bob)

2) give another worker a list of operations to execute once the tensor arrives.

# send Bob an operation to execute once the promise x is fulfilled - returns promise y
ptr_to_y_promise = ptr_to_x_promise + ptr_to_x_promise 

# send Bob an operation to execute once the promise y is fulfilled
ptr_to_z_promise = ptr_to_y_promise + ptr_to_y_promise

3) keep the promise at any time

ptr_to_z = x.keep(th.tensor([1,2,3])
z = ptr_to_z.get()

However, while this above example uses a PromiseTensor, the promise architecture should be created as a generic Promise object (not unlike our generic Pointer object).

Status Type

Most helpful comment

UPDATE: So far I've got basic local promises working for addition.

a = sy.Promises.FloatTensor(shape=th.Size((3,3)))
b = sy.Promises.FloatTensor(shape=th.Size((3,3)))

print("Promise A:")
print(a)

y = a + b
z = y + y

print("\nPromise Z:")
print(z)

a.keep(th.ones(3,3))

print("\nZ After Keep A:")
print(z)

b.keep(th.ones(3,3))

print("\nZ After Keep B:")
print(b)

Returns:

Promise A:
(Wrapper)>PromiseTensor>None

Promise Z:
(Wrapper)>PromiseTensor>None

Z After Keep A:
(Wrapper)>PromiseTensor>None

Z After Keep B:
tensor([[1., 1., 1.],
        [1., 1., 1.],
        [1., 1., 1.]])

Note that the PromiseTensor piece of the chain disappears entirely when it is kept. Note further that I've created a sy.Promises package which allow for initialization of promises with a specific type and shape.

All 8 comments

Out of curiosity: Is there any inherent time-dimensionality to this Promise work, such as when the promise is expected to be fulfilled? This might be important for real-life applications I reckon.

Interesting feature idea! I hadn't considered it but it seems plausible that someone would use it! What kind of use case do you think might be interested in such a feature?

I could see one of the use cases being if in the context of some contractual obligation the promise is guaranteed to be delivered on a specific date (or in stages). However, if the promise is not delivered on time, some contractual agreement is violated, and thereby some punishment say in the form of a payment is incurred... This is quite generic though. For a more concrete example, the promise can be a target indicator value for gauging the impact of an ad campaign on a social media platform. The target indicator can be the popularity of the company running the campaign.

Will keep that in mind. At the moment, Promise/PrmoiseTensor is mostly a method for constructing asynchronous code execution to increase low level performance. There are a lot of other features that we would need in order to get promises to be more of a user-facing feature.

UPDATE: So far I've got basic local promises working for addition.

a = sy.Promises.FloatTensor(shape=th.Size((3,3)))
b = sy.Promises.FloatTensor(shape=th.Size((3,3)))

print("Promise A:")
print(a)

y = a + b
z = y + y

print("\nPromise Z:")
print(z)

a.keep(th.ones(3,3))

print("\nZ After Keep A:")
print(z)

b.keep(th.ones(3,3))

print("\nZ After Keep B:")
print(b)

Returns:

Promise A:
(Wrapper)>PromiseTensor>None

Promise Z:
(Wrapper)>PromiseTensor>None

Z After Keep A:
(Wrapper)>PromiseTensor>None

Z After Keep B:
tensor([[1., 1., 1.],
        [1., 1., 1.],
        [1., 1., 1.]])

Note that the PromiseTensor piece of the chain disappears entirely when it is kept. Note further that I've created a sy.Promises package which allow for initialization of promises with a specific type and shape.

And now TorchHook includes a method which hooks all torch.Tensor methods for use in PromiseTensor

Screen Shot 2019-08-21 at 8 08 38 PM

Made some progress.

This issue has been marked stale because it has been open 30 days with no activity. Leave a comment or remove the stale label to unmark it. Otherwise, this will be closed in 7 days.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tblazina picture tblazina  路  3Comments

swaroopch picture swaroopch  路  4Comments

akirahirohito picture akirahirohito  路  3Comments

alberduris picture alberduris  路  3Comments

jvmncs picture jvmncs  路  3Comments