def send_worker_done(self): """Sends the worker done signal to the parameter server.""" data = {} data['worker_done'] = self.get_worker_id() # Request a commit from the parameter server. self.socket.sendall(b'c') send_data(self.socket, data)
def commit(self, residual): """Sends the gradient residual to the parameter server.""" # Prepare the datastructure. data = {} data['worker_id'] = self.get_worker_id() data['residual'] = residual # Request a commit from the parameter server. self.socket.sendall(b'c') # Send the data to the paramter server. send_data(self.socket, data)
def commit(self, delta): """Sends the delta to the parameter server.""" # Prepare the datastructure. data = {} data['worker_id'] = self.get_worker_id() data['delta'] = delta # Request a commit from the parameter server. self.socket.sendall(b'c') # Send the data to the parameter server. send_data(self.socket, data)
def handle_pull(self, conn, addr): """Handles parameter requests coming from the workers. This will actually send the model parameters to the requesting host. # Arguments: conn: socket. The opened connection. addr: addr. Address of the remote host. """ # Fetch the raw center variables. with self.mutex: center_variable = self.model.get_weights() # Send the data over the socket. send_data(conn, center_variable)
def commit(self, residual): #establish the connection to its parent #need a way to coordinate the parent socket connection setup between different machine if self.socket_parent is None: self.connect() data = {} data['worker_id'] = -1 data['residual'] = residual with self.out_mutex: # Request a commit from the parameter server. self.socket_parent.sendall(b'h') # Send the data to the paramter server. send_data(self.socket_parent, data)
def handle_pull(self, conn, addr): """Handles parameter requests coming from the workers. This will actually send the model parameters to the requesting host. # Arguments: conn: socket. The opened connection. addr: addr. Address of the remote host. """ # Fetch the raw center variables. with self.mutex: cv = copy.deepcopy(self.center_variable) # Send the data over the socket. if addr[0] != '127.0.0.1': with self.out_mutex: #send confirmation conn.sendall(b'a') send_data(conn, cv) else: #send confirmation conn.sendall(b'a') send_data(conn, cv)
def handle_pull(self, conn, addr): """Handles parameter requests coming from the workers. This will actually send the model parameters to the requesting host. This is a specific implementation for DynSGD. # Arguments: conn: socket. The opened connection. addr: addr. Address of the remote host. """ # Fetch the raw center variables. with self.mutex: center_variable = self.model.get_weights() cv = copy.deepcopy(center_variable) # Allocate a new dictionary. data = {} # Store the model (m). data['model'] = cv # Store the number of updates (u) the PS executed. data['update'] = self.num_updates # Send the data over the socket. send_data(conn, data)