Documentation ¶
Index ¶
- func ConstantValidation(_ *rand.Rand, _, _ int) float64
- func RandomValidation(rand *rand.Rand, _, _ int) float64
- func TrialIDMetric(_ *rand.Rand, trialID, _ int) float64
- type Checkpoint
- type Close
- type Create
- func CreateFromProto(protoSearcherOp *experimentv1.SearcherOperation_CreateTrial, ...) (*Create, error)
- func NewCreate(rand *nprand.State, s HParamSample, sequencerType model.WorkloadSequencerType) Create
- func NewCreateFromCheckpoint(rand *nprand.State, s HParamSample, parentID model.RequestID, ...) Create
- type CustomSearchMethod
- type EventsWatcher
- type HParamSample
- type Operation
- type OperationList
- type OperationType
- type OperationWithType
- type PartialUnits
- type Requested
- type SearchMethod
- type SearchMethodType
- type Searcher
- func (s *Searcher) GetCustomSearcherEventQueue() (*SearcherEventQueue, error)
- func (s *Searcher) InitialOperations() ([]Operation, error)
- func (s *Searcher) Progress() float64
- func (s *Searcher) Record(ops []Operation)
- func (s *Searcher) Restore(state json.RawMessage) error
- func (s *Searcher) SetCustomSearcherProgress(progress float64) error
- func (s *Searcher) SetTrialProgress(requestID model.RequestID, progress PartialUnits)
- func (s *Searcher) Snapshot() (json.RawMessage, error)
- func (s *Searcher) TrialClosed(requestID model.RequestID) ([]Operation, error)
- func (s *Searcher) TrialCreated(requestID model.RequestID) ([]Operation, error)
- func (s *Searcher) TrialExitedEarly(requestID model.RequestID, exitedReason model.ExitedReason) ([]Operation, error)
- func (s *Searcher) TrialIsClosed(requestID model.RequestID) bool
- func (s *Searcher) TrialIsCreated(requestID model.RequestID) bool
- func (s *Searcher) ValidationCompleted(requestID model.RequestID, metric interface{}, op ValidateAfter) ([]Operation, error)
- type SearcherEventQueue
- func (q *SearcherEventQueue) Enqueue(event *experimentv1.SearcherEvent)
- func (q *SearcherEventQueue) GetEvents() []*experimentv1.SearcherEvent
- func (q *SearcherEventQueue) MarshalJSON() ([]byte, error)
- func (q *SearcherEventQueue) RemoveUpTo(eventID int) error
- func (q *SearcherEventQueue) UnmarshalJSON(data []byte) error
- func (q *SearcherEventQueue) Unwatch(id uuid.UUID)
- func (q *SearcherEventQueue) Watch() (EventsWatcher, error)
- type SearcherState
- type SetSearcherProgress
- type Shutdown
- type Simulation
- type SimulationResults
- type ValidateAfter
- type ValidationFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantValidation ¶
ConstantValidation returns the same validation metric for all validation steps.
func RandomValidation ¶
RandomValidation returns a random validation metric for each validation step.
Types ¶
type Checkpoint ¶
Checkpoint indicates which trial the trial created by a Create should inherit from.
func (Checkpoint) String ¶
func (c Checkpoint) String() string
type Close ¶
Close the trial with the given trial ID.
func CloseFromProto ¶
func CloseFromProto( op *experimentv1.SearcherOperation_CloseTrial, ) (*Close, error)
CloseFromProto returns a Close operation from its protobuf representation.
func (Close) GetRequestID ¶
GetRequestID implemented Requested.
type Create ¶
type Create struct { RequestID model.RequestID `json:"request_id"` // TrialSeed must be a value between 0 and 2**31 - 1. TrialSeed uint32 `json:"trial_seed"` Hparams HParamSample `json:"hparams"` Checkpoint *Checkpoint `json:"checkpoint"` WorkloadSequencerType model.WorkloadSequencerType `json:"workload_sequencer_type"` }
Create a new trial for the search method.
func CreateFromProto ¶
func CreateFromProto( protoSearcherOp *experimentv1.SearcherOperation_CreateTrial, sequencerType model.WorkloadSequencerType, ) (*Create, error)
CreateFromProto initializes a new Create operation from an experimentv1.SearcherOperation_CreateTrial.
func NewCreate ¶
func NewCreate( rand *nprand.State, s HParamSample, sequencerType model.WorkloadSequencerType, ) Create
NewCreate initializes a new Create operation with a new request ID and the given hyperparameters.
func NewCreateFromCheckpoint ¶
func NewCreateFromCheckpoint( rand *nprand.State, s HParamSample, parentID model.RequestID, sequencerType model.WorkloadSequencerType, ) Create
NewCreateFromCheckpoint initializes a new Create operation with a new request ID and the given hyperparameters and checkpoint to initially load from.
func (Create) GetRequestID ¶
GetRequestID implemented Requested.
type CustomSearchMethod ¶
type CustomSearchMethod interface {
// contains filtered or unexported methods
}
CustomSearchMethod is the interface for the custom search method.
type EventsWatcher ¶
type EventsWatcher struct { ID uuid.UUID C <-chan []*experimentv1.SearcherEvent }
EventsWatcher has a channel which allows communication to the GET searcher events API.
type HParamSample ¶
type HParamSample map[string]interface{}
HParamSample is a sampling of the hyperparameters for a model.
type Operation ¶
type Operation interface{}
Operation represents the base interface for possible operations that a search method can return.
type OperationList ¶
type OperationList []Operation
OperationList is []Operation that handles marshaling and unmarshaling heterogeneous operations to and from their correct underlying types.
func (OperationList) MarshalJSON ¶
func (l OperationList) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*OperationList) UnmarshalJSON ¶
func (l *OperationList) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type OperationType ¶
type OperationType int
OperationType encodes the underlying type of an Operation for serialization.
const ( CreateOperation OperationType = 0 TrainOperation OperationType = 1 ValidateOperation OperationType = 2 CloseOperation OperationType = 4 ValidateAfterOperation OperationType = 5 SetSearcherProgressOperation OperationType = 6 )
All the operation types that support serialization.
type OperationWithType ¶
type OperationWithType struct { OperationType Operation }
OperationWithType is an operation with a serializable repr of its underlying type.
type PartialUnits ¶
type PartialUnits float64
PartialUnits represent partial epochs, batches or records where the Unit is implied.
type Requested ¶
Requested is a convenience interface for operations that were requested by a searcher method for a specific trial.
type SearchMethod ¶
type SearchMethod interface { // TODO: refactor as model.Snapshotter interface or something model.Snapshotter expconf.InUnits // contains filtered or unexported methods }
SearchMethod is the interface for hyper-parameter tuning methods. Implementations of this interface should use pointer receivers to ensure interface equality is calculated through pointer equality.
func NewSearchMethod ¶
func NewSearchMethod(c expconf.SearcherConfig) SearchMethod
NewSearchMethod returns a new search method for the provided searcher configuration.
type SearchMethodType ¶
type SearchMethodType string
SearchMethodType is the type of a SearchMethod. It is saved in snapshots to be used when shimming json blobs of searcher snapshots.
const ( // SingleSearch is the SearchMethodType for a single searcher. SingleSearch SearchMethodType = "single" // RandomSearch is the SearchMethodType for a random searcher. RandomSearch SearchMethodType = "random" // GridSearch is the SearchMethodType for a grid searcher. GridSearch SearchMethodType = "grid" // AdaptiveSearch is the SearchMethodType for an adaptive searcher. AdaptiveSearch SearchMethodType = "adaptive" // ASHASearch is the SearchMethodType for an ASHA searcher. ASHASearch SearchMethodType = "asha" // AdaptiveASHASearch is the SearchMethodType for an adaptive ASHA searcher. AdaptiveASHASearch SearchMethodType = "adaptive_asha" // CustomSearch is the SearchMethodType for a custom searcher. CustomSearch SearchMethodType = "custom_search" )
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher encompasses the state as the searcher progresses using the provided search method.
func NewSearcher ¶
func NewSearcher(seed uint32, method SearchMethod, hparams expconf.Hyperparameters) *Searcher
NewSearcher creates a new Searcher configured with the provided searcher config.
func (*Searcher) GetCustomSearcherEventQueue ¶
func (s *Searcher) GetCustomSearcherEventQueue() (*SearcherEventQueue, error)
GetCustomSearcherEventQueue returns the searcher's custom searcher event queue. It returns an error if the search method is not a custom searcher.
func (*Searcher) InitialOperations ¶
InitialOperations return a set of initial operations that the searcher would like to take. This should be called only once after the searcher has been created.
func (*Searcher) Record ¶
Record records operations that were requested by the searcher for a specific trial.
func (*Searcher) Restore ¶
func (s *Searcher) Restore(state json.RawMessage) error
Restore loads a searcher from prior state.
func (*Searcher) SetCustomSearcherProgress ¶
SetCustomSearcherProgress sets the custom searcher progress.
func (*Searcher) SetTrialProgress ¶
func (s *Searcher) SetTrialProgress(requestID model.RequestID, progress PartialUnits)
SetTrialProgress informs the searcher of the progress of a given trial.
func (*Searcher) Snapshot ¶
func (s *Searcher) Snapshot() (json.RawMessage, error)
Snapshot returns a searchers current state.
func (*Searcher) TrialClosed ¶
TrialClosed informs the searcher that the trial has been closed as a result of a Close operation.
func (*Searcher) TrialCreated ¶
TrialCreated informs the searcher that a trial has been created as a result of a Create operation.
func (*Searcher) TrialExitedEarly ¶
func (s *Searcher) TrialExitedEarly( requestID model.RequestID, exitedReason model.ExitedReason, ) ([]Operation, error)
TrialExitedEarly indicates to the searcher that the trial with the given trialID exited early.
func (*Searcher) TrialIsClosed ¶
TrialIsClosed returns true if the close has been recorded with a TrialClosed call.
func (*Searcher) TrialIsCreated ¶
TrialIsCreated returns true if the creation has been recorded with a TrialCreated call.
func (*Searcher) ValidationCompleted ¶
func (s *Searcher) ValidationCompleted( requestID model.RequestID, metric interface{}, op ValidateAfter, ) ([]Operation, error)
ValidationCompleted informs the searcher that a validation for the trial was completed.
type SearcherEventQueue ¶
type SearcherEventQueue struct {
// contains filtered or unexported fields
}
SearcherEventQueue stores the list of custom searcher events and the event that was event that was processed last by client and acknowledged by master.
func (*SearcherEventQueue) Enqueue ¶
func (q *SearcherEventQueue) Enqueue(event *experimentv1.SearcherEvent)
Enqueue adds an event to the queue, setting its ID automatically.
func (*SearcherEventQueue) GetEvents ¶
func (q *SearcherEventQueue) GetEvents() []*experimentv1.SearcherEvent
GetEvents returns all the events.
func (*SearcherEventQueue) MarshalJSON ¶
func (q *SearcherEventQueue) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*SearcherEventQueue) RemoveUpTo ¶
func (q *SearcherEventQueue) RemoveUpTo(eventID int) error
RemoveUpTo removes all events up to and including the one with the given event ID.
func (*SearcherEventQueue) UnmarshalJSON ¶
func (q *SearcherEventQueue) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
func (*SearcherEventQueue) Unwatch ¶
func (q *SearcherEventQueue) Unwatch(id uuid.UUID)
Unwatch unregisters an eventsWatcher.
func (*SearcherEventQueue) Watch ¶
func (q *SearcherEventQueue) Watch() (EventsWatcher, error)
Watch creates an eventsWatcher. If any events are currently in the queue, they are immediately sent; otherwise, the channel in the result will block until an event comes in.
type SearcherState ¶
type SearcherState struct { TrialsRequested int `json:"trials_requested"` TrialsCreated map[model.RequestID]bool `json:"trials_created"` TrialsClosed map[model.RequestID]bool `json:"trials_closed"` Exits map[model.RequestID]bool `json:"exits"` Cancels map[model.RequestID]bool `json:"cancels"` Failures map[model.RequestID]bool `json:"failures"` TrialProgress map[model.RequestID]PartialUnits `json:"trial_progress"` Shutdown bool `json:"shutdown"` CompletedOperations map[string]ValidateAfter `json:"completed_operations"` Rand *nprand.State `json:"rand"` SearchMethodState json.RawMessage `json:"search_method_state"` }
SearcherState encapsulates all persisted searcher state.
type SetSearcherProgress ¶
type SetSearcherProgress struct {
Progress float64
}
SetSearcherProgress sets the progress of the custom searcher.
func SetSearcherProgressFromProto ¶
func SetSearcherProgressFromProto( op *experimentv1.SearcherOperation_SetSearcherProgress, ) SetSearcherProgress
SetSearcherProgressFromProto creates a SetSearcherProgress from its protobuf representation.
type Shutdown ¶
Shutdown marks the searcher as completed.
func NewShutdown ¶
func NewShutdown() Shutdown
NewShutdown initializes a Shutdown operation for the searcher.
func ShutdownFromProto ¶
func ShutdownFromProto( op *experimentv1.SearcherOperation_ShutDown, ) (*Shutdown, error)
ShutdownFromProto creates a Shutdown from its protobuf representation.
type Simulation ¶
type Simulation struct { Results SimulationResults `json:"results"` Seed int64 `json:"seed"` }
Simulation holds the configuration and results of simulated run of a searcher.
func Simulate ¶
func Simulate( s *Searcher, seed *int64, valFunc ValidationFunction, randomOrder bool, metricName string, ) (Simulation, error)
Simulate simulates the searcher.
type SimulationResults ¶
type SimulationResults map[model.RequestID][]ValidateAfter
SimulationResults holds all created trials and all executed workloads for each trial.
func (SimulationResults) MarshalJSON ¶
func (s SimulationResults) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
type ValidateAfter ¶
ValidateAfter is an operation emitted by search methods to signal the trial train until its total batches trained equals the specified length.
func NewValidateAfter ¶
func NewValidateAfter(requestID model.RequestID, length uint64) ValidateAfter
NewValidateAfter returns a new train operation.
func ValidateAfterFromProto ¶
func ValidateAfterFromProto( op *experimentv1.TrialOperation_ValidateAfter, ) (*ValidateAfter, error)
ValidateAfterFromProto creates a ValidateAfter operation from its protobuf representation.
func (ValidateAfter) GetRequestID ¶
func (t ValidateAfter) GetRequestID() model.RequestID
GetRequestID implemented Requested.
func (ValidateAfter) String ¶
func (t ValidateAfter) String() string
func (ValidateAfter) ToProto ¶
func (t ValidateAfter) ToProto() *experimentv1.ValidateAfterOperation
ToProto converts a searcher.ValidateAfter to its protobuf representation.