Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
singa::Server Class Reference

Public Member Functions

 Server (int thread_id, int group_id, int server_id)
 
void Setup (const UpdaterProto &proto, const std::vector< int > &slice2group, const std::vector< int > &slice2server)
 
void Run ()
 
const int grp_id () const
 
const int id () const
 

Protected Member Functions

virtual MsgHandleGet (Msg **msg)
 Process GET request. More...
 
const std::vector< Msg * > HandleUpdate (Msg **msg)
 Process Update request. More...
 
virtual MsgHandlePut (Msg **msg)
 Process PUT request. More...
 
virtual MsgHandleSyncRequest (Msg **msg)
 Handle sync request from other server groups. More...
 
void HandleSyncResponse (Msg **msg)
 Handle sync response. More...
 

Protected Attributes

int thread_id_
 
int grp_id_
 
int id_
 
Updaterupdater_
 map from slice ID to slice and deleted in the destructor
 
std::unordered_map< int,
ParamEntry * > 
shard_
 
std::vector< int > slice2group_
 
std::vector< int > slice2server_
 num of updates from last sync with master server group for a param/slice
 
std::vector< int > nUpdates_
 num of sync requests that have not been responded
 
std::vector< int > nPendingSync_
 
std::vector< Blob< float > > last_sync_
 
std::unordered_map< int,
std::vector< Msg * > > 
buffer_requests_
 

Member Function Documentation

virtual Msg* singa::Server::HandleGet ( Msg **  msg)
protectedvirtual

Process GET request.

Returns
the orignal message or a response message which contains the values of the Param with the request version.
virtual Msg* singa::Server::HandlePut ( Msg **  msg)
protectedvirtual

Process PUT request.

Returns
the original message or response message. If we don't want to acknowledge the put request, then return nullptr.
virtual Msg* singa::Server::HandleSyncRequest ( Msg **  msg)
protectedvirtual

Handle sync request from other server groups.

It adds updates of Param (slice) from other server groups directly to local Param (slice). Currently, each Param (slice) has a master group, i.e., slice2group_[sliceid], which would receive such requests from all other server groups for the Param object.

Parameters
msgrequest msg containing the parameter updates
Returns
response msg that contains the fresh parameter values.
void singa::Server::HandleSyncResponse ( Msg **  msg)
protected

Handle sync response.

The response msg includes the latest values of a Param object, for which this server sent the sync request to the master/maintainer group. The local Param values are replaced with the addition result of local udpates since the sync request was sent and the received Param values.

Parameters
responsemessage
const std::vector<Msg*> singa::Server::HandleUpdate ( Msg **  msg)
protected

Process Update request.

It waits until received the gradients from all workers from the same worker group. After updating, it responses to each sender with the new Param values. It may generate a sync message to the server group that maintains the global version of the updated Param (slice).

Note: there is no counter for each worker group on the number of received update requests. Hence it is possible that the server would conduct the update when it receives x requests from group a and y requests from group b where x + y = group size. To avoid this problem, we can

  1. maintain request list for each group for each Param at the server side
  2. do not span a worker group among multiple nodes. then the updates from the same group would be locally aggregated on the worker node. And the server would conduct the update immediately after receiving the aggregated request.
  3. launch only one worker group.
Returns
the orignal message or response message

The documentation for this class was generated from the following file: