pserver

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PsDesired is etcd path for store desired pserver count
	PsDesired = "/ps_desired"
	// PsPath is the base dir for pserver to store their addr
	PsPath = "/ps/"
	// PsCheckpoint is the etcd path for store checkpoints information
	PsCheckpoint = "/checkpoints/"
)
View Source
const (
	AlreadyInitialized = "pserver already initialized"
	Uninitialized      = "pserver not fully initialized"
	WrongChecksum      = "checkpoint file checksum validation failed"
)

RPC error message.

Variables

View Source
var ErrCheckpointNotFound = errors.New("checkpoint not found in etcd")

ErrCheckpointNotFound indicates that the pserver checkpoint could not be found.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint []parameterCheckpoint

Checkpoint is the pserver shard persist in file.

func LoadCheckpoint

func LoadCheckpoint(e KVStore, idx int) (Checkpoint, error)

LoadCheckpoint loads checkpoint from file.

type ElementType

type ElementType int

ElementType is the type of elements of a Parameter.

const (
	Int32 ElementType = iota
	UInt32
	Int64
	UInt64
	Float32
	Float64
)

Supported element types.

type EtcdClient

type EtcdClient struct {
	// contains filtered or unexported fields
}

EtcdClient is the etcd client that the pserver uses for fault tolerance, service registry and coordination.

func NewEtcdClient

func NewEtcdClient(endpoints string, numPservers int, dialtimeout time.Duration, ttlSec int) *EtcdClient

NewEtcdClient creates an EtcdClient

func (*EtcdClient) GetKey

func (e *EtcdClient) GetKey(key string, timeout time.Duration) ([]byte, error)

GetKey gets the value by the specified key

func (*EtcdClient) PutKey

func (e *EtcdClient) PutKey(key string, value []byte, timeout time.Duration, withLease bool) error

PutKey put into etcd with value by key specified

func (*EtcdClient) Register

func (e *EtcdClient) Register(port int) (int, error)

Register registers the pserver on etcd

Register returns the index of the current pserver.

func (*EtcdClient) Shutdown

func (e *EtcdClient) Shutdown() error

Shutdown shuts down the etcd client gracefully.

type Gradient

type Gradient Parameter

Gradient is the gradient of the parameter.

type KVStore

type KVStore interface {
	GetKey(key string, timeout time.Duration) ([]byte, error)
	PutKey(key string, value []byte, timeout time.Duration, withLease bool) error
}

type Parameter

type Parameter struct {
	Name        string
	ElementType ElementType
	Content     []byte
}

Parameter is a piece of data to sync with the parameter server.

func (Parameter) String

func (p Parameter) String() string

type ParameterWithConfig

type ParameterWithConfig struct {
	Param  Parameter
	Config []byte // parameter configuration in Proto Buffer format
}

ParameterWithConfig contains the parameter and the configuration.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the RPC service for pserver.

func NewService

func NewService(idx int, interval time.Duration, path string, client KVStore, cp Checkpoint) (*Service, error)

NewService creates a new service, will bypass etcd registration if no endpoints specified. It will recovery from checkpoint file if a exists a specified checkpoint.

func (*Service) FinishInitParams

func (s *Service) FinishInitParams(_ int, _ *int) error

FinishInitParams tells the parameter server that the parameter initialization has finished.

func (*Service) GetParam

func (s *Service) GetParam(name string, parameter *Parameter) error

GetParam gets parameters from the parameter server.

func (*Service) InitParam

func (s *Service) InitParam(paramWithConfigs ParameterWithConfig, _ *int) error

InitParam initializes a parameter.

func (*Service) SendGrad

func (s *Service) SendGrad(g Gradient, _ *int) error

SendGrad sends gradient to parameter servers for parameter optimization.

Directories

Path Synopsis
c

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL