-
-
Notifications
You must be signed in to change notification settings - Fork 2k
CrypTen Message Handler #3676
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
CrypTen Message Handler #3676
Conversation
|
Check out this pull request on Review Jupyter notebook visual diffs & provide feedback on notebooks. Powered by ReviewNB |
df97851 to
7f79b48
Compare
|
|
||
| sy.local_worker.add_crypten_support() | ||
| sy.local_worker._set_rank_to_worker_id(rank_to_worker_id) | ||
| sy.local_worker.rank_to_worker_id = rank_to_worker_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of ugly. This rank_to_worker_id is used in the load function from crypten/__init__py...Thinking how we could remove this or refactor the load function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add some functions that take a worker as argument
syft/__init__.py
Outdated
| else: | ||
| logger.info("TF Encrypted Keras not available.") | ||
|
|
||
| if dependency_check.crypten_available: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this here and not in syft/generic/frameworks/types.py because of circular dependecies.
7f79b48 to
5f0b715
Compare
5f0b715 to
4ff0c94
Compare
Codecov Report
@@ Coverage Diff @@
## crypten #3676 +/- ##
===========================================
- Coverage 94.78% 94.72% -0.07%
===========================================
Files 184 193 +9
Lines 18214 18837 +623
===========================================
+ Hits 17265 17843 +578
- Misses 949 994 +45
|
youben11
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't the initial design to leave every worker choose the message handlers to use, instead of adding all registered message handler in syft.framework_message_handler?
The initial design (like we had before) was like that (by using Now we automatically add the support if we detect a framework (currently is only for I tried to follow those steps from the discussion between us and @karlhigley: Or shouldn't we add the handlers automatically? |
|
yeah, that's what I meant, like every message_handler have a function for checking if the deps are okay, and every worker implements the message handlers he need (if the deps are okay for that specific message handler). |
Isn't that happening in |
|
yeah, but it is kind of decoupled from the message handler itself. I was thinking more like the message handler checking that in a static function, and workers using some handlers if their deps are okay. |
| return framework.lower() in framework_packages | ||
|
|
||
|
|
||
| BaseWorker.register_message_handlers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youben11 moved the logic to the worker level.
Something like this you meant?
@karlhigley what do you think about this?
| @staticmethod | ||
| def register_message_handlers(): | ||
| if sy.dependency_check.crypten_available: | ||
| from syft.frameworks.crypten.message_handler import CryptenMessageHandler | ||
|
|
||
| BaseWorker._framework_message_handler["crypten"] = CryptenMessageHandler | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a function to do that, that attribute could be initialized at first, and message handlers would be appended only if the dependency check passes, which is something the message hander itself checks for (with a static function MessageHandler.is_supported() for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...or couldn't we add this registry mechanism directly in the CryptenMessageHandler class file (if we import that file it means we have the dependencies hence we should add it to the _framework_message_handlers?)
@karlhigley what do you think?
| rank = None | ||
| for r, worker_id in self.worker.rank_to_worker_id.items(): | ||
| if worker_id == self.worker.id: | ||
| rank = r | ||
| break | ||
|
|
||
| assert rank is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is used twice, could be refactor. it?
Description
Add a message handler for the CrypTen framework that should route the messages to the correct method.
Affected Dependencies
List any dependencies that are required for this change.
How has this been tested?
Checklist