Skip to content
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

Add latency simulation to Virtual workers #3007

Closed
LaRiffle opened this issue Feb 4, 2020 · 6 comments · Fixed by #3070
Closed

Add latency simulation to Virtual workers #3007

LaRiffle opened this issue Feb 4, 2020 · 6 comments · Fixed by #3070

Comments

@LaRiffle
Copy link
Collaborator

@LaRiffle LaRiffle commented Feb 4, 2020

Describe the solution you'd like
It would be great to add an option to simulate latency on virtual workers while sending message.
Basically just add a small sleep in the _recv_msg or _send_msg virtual worker methods.

@jefersonf

This comment has been minimized.

Copy link
Member

@jefersonf jefersonf commented Feb 4, 2020

What do you mean by latency simulation? Would it be an new option to a VirtualWorker like add_latency=100?. Like the following example.

...
import time

class VirtualWorker(BaseWorker, FederatedClient):
    def _send_msg(self, message: bin, location: BaseWorker, latency: int = 0) -> bin:
        time.sleep(latency)
        return location._recv_msg(message)
@BBloggsbott

This comment has been minimized.

Copy link

@BBloggsbott BBloggsbott commented Feb 13, 2020

I'd like to implement this

@jefersonf

This comment has been minimized.

Copy link
Member

@jefersonf jefersonf commented Feb 13, 2020

Hi @BBloggsbott, I tried to tackle this. And I've actually started on, if you would like to give some help please take a look at this branch.

In fact, the following case is working so far:

import torch
import syft as sy
hook = sy.TorchHook(torch)

alice = sy.VirtualWorker(id="alice", hook=hook)
bob  = sy.VirtualWorker(id="bob", hook=hook)
x = torch.tensor([1,2,3])

# alice waits 2 seconds before sending 'x' to bob.
alice.send(x, bob, pending_time=2)

@BBloggsbott

This comment has been minimized.

Copy link

@BBloggsbott BBloggsbott commented Feb 14, 2020

@jefersonf Why not just use the change you mentioned here? I feel only the virtual workers will need to simulate latency.

@jefersonf

This comment has been minimized.

Copy link
Member

@jefersonf jefersonf commented Feb 14, 2020

@jefersonf Why not just use the change you mentioned here? I feel only the virtual workers will need to simulate latency.

At first I thought so too, but I think in cases where a tensor is sent to a worker like in the following:

torch.tensor([1,2,3]).send(alice, pending_time=2)

the same behavior should be hold.

@BBloggsbott

This comment has been minimized.

Copy link

@BBloggsbott BBloggsbott commented Feb 14, 2020

Ah. Okay.

How can I help with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.