Skip to content

Running crypten computation either with plans or jailing#3410

Merged
gmuraru merged 14 commits intocryptenfrom
youben11/run-jail
May 5, 2020
Merged

Running crypten computation either with plans or jailing#3410
gmuraru merged 14 commits intocryptenfrom
youben11/run-jail

Conversation

@youben11
Copy link
Member

@youben11 youben11 commented Apr 26, 2020

Description

At the moment we have two ways of running crypten computations, either using plans or jails, instead of having two different branches that have similar functionalities, better to be able to use both in parallel.

This PR introduce a new message type CryptenInitJail to start a JailRunner on other syft workers, need to merge into syft-proto OpenMined/syft-proto#93. This way we can send messages to initiate either plans or jails.

Type of change

Please mark options that are relevant.

  • Added/Modified tutorials
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

Copy link
Contributor

@LaRiffle LaRiffle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny changes and we're done :)

so they can communicate and exchange tensors and shares while doing computation. This message
allows the exchange of information such as the ip and port of the master party to connect to,
as well as the rank of the party to run and the number of parties involved. Compared to
CryptenInitPlan, this message also send two extra field, a JailRunner and a crypten model."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CryptenInitPlan, this message also send two extra field, a JailRunner and a crypten model."""
CryptenInitPlan, this message also sends two extra fields, a JailRunner and a Crypten model."""

return (self.crypten_context,)

@staticmethod
def simplify(worker: AbstractWorker, ptr: "CryptenInitJail") -> tuple:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename ptr -> message ?

Comment on lines +794 to +796
context = msg_tuple[0:4]
jail_runner = msg_tuple[4]
model = msg_tuple[5]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
context = msg_tuple[0:4]
jail_runner = msg_tuple[4]
model = msg_tuple[5]
*context, jail_runner, model = msg_tuple

rank = r
break

assert rank != None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert rank != None
assert rank is not None

CryptenInitPlan, this message also send two extra field, a JailRunner and a crypten model."""

def __init__(self, crypten_context, jail_runner, model=None):
self.crypten_context = crypten_context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess one example of Crypten context would be useful

@youben11 youben11 requested a review from LaRiffle April 27, 2020 04:25
@@ -141,7 +141,8 @@ def __init__(
self._hook_native_tensor(torch.Tensor, TorchTensor)

if dependency_check.crypten_available:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Should this be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I shouldn't have pushed that, I was only commenting this to not hook mpc tensor to get cat and stuff working, will just re-enable it for the moment

@gmuraru gmuraru force-pushed the crypten branch 2 times, most recently from 91acf35 to 5b69d19 Compare April 29, 2020 05:30
gmuraru and others added 6 commits May 1, 2020 05:12
* Context of computation for crypten (#2963)

* New message type for crypten party initialization

* Handle CryptenInit message by running local party

* Define a new context of computation for crypten

The new context of computation can run parties that are distributed
across syft workers. The communication of crypten parties remains the
same, however, syft workers handle initialization and the serialization
of return values.

* updated docs

* testing crypten context

* fix: was setting the bad env variable

DISTRIBUTED_BACKEND should have been set and not BACKEND

* test serde of CryptenInit message

* add crypten as core deps, this should change to extra

* delete useless comment

* fix: list CryptenInit in OBJ_SIMPLIFIER_AND_DETAILERS

* fix msgpack tests

* run black

* don't cover empty function

* Init Crypten Plan

* Remove python 3.6 from github actions

* Remove SyftCrypTensor as wrapper from MPCTensor

* Remove SyftCrypTensor from export

* Check for is_wrapper in placeholder

* Add placeholder attribute

* Bug Fix Message

* Add serde test

* Old CrypTen version

* Add crypten to execution

* wrap our load function around crypten.load

* Update syft/frameworks/crypten/__init__.py

Co-Authored-By: Ayoub Benaissa <ayouben9@gmail.com>

* Rework crypten integration for plans

* linter fix

* Remove duplicate test

Co-Authored-By: Ayoub Benaissa <ayouben9@gmail.com>

* Crypten track master

* Remove SyftCryptensor as a dependency

* Remove python 3.6

* Use correct commit

* Add MPCTensor as FrameworkTensor and remove SyftCrypTensor

* remove duplicated CrypTenInit

* Review pass1

Co-authored-by: Ayoub Benaissa <ayouben9@gmail.com>
@youben11 youben11 force-pushed the youben11/run-jail branch from 6ead606 to 6499207 Compare May 1, 2020 04:13
Copy link
Contributor

@LaRiffle LaRiffle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

def detail(worker: AbstractWorker, msg_tuple: tuple) -> "CryptenInitJail":
"""
This function takes the simplified tuple version of this message and converts
it into an CryptenInitJail. The simplify() method runs the inverse of this method.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TYPO: an -> a.

break

assert rank != None
assert rank is not None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this :D

Copy link
Member

@gmuraru gmuraru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gmuraru gmuraru merged commit 7a5420b into crypten May 5, 2020
@gmuraru gmuraru deleted the youben11/run-jail branch May 5, 2020 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants