searcher

package
v0.750.8 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstantValidation added in v0.750.0

func ConstantValidation(_ *rand.Rand, _, _ int) float64

ConstantValidation returns the same validation metric for all validation steps.

func RandomValidation added in v0.750.0

func RandomValidation(rand *rand.Rand, _, _ int) float64

RandomValidation returns a random validation metric for each validation step.

func TrialIDMetric added in v0.750.0

func TrialIDMetric(_ *rand.Rand, trialID, _ int) float64

TrialIDMetric returns the trialID as the metric for all validation steps.

Types

type Checkpoint added in v0.750.0

type Checkpoint struct {
	RequestID model.RequestID
}

Checkpoint indicates which trial the trial created by a Create should inherit from.

func (Checkpoint) String added in v0.750.0

func (c Checkpoint) String() string

type Close added in v0.750.0

type Close struct {
	RequestID model.RequestID `json:"request_id"`
}

Close the trial with the given trial ID.

func CloseFromProto added in v0.750.0

func CloseFromProto(
	op *experimentv1.SearcherOperation_CloseTrial,
) (*Close, error)

CloseFromProto returns a Close operation from its protobuf representation.

func NewClose added in v0.750.0

func NewClose(requestID model.RequestID) Close

NewClose initializes a new Close operation for the request ID.

func (Close) GetRequestID added in v0.750.0

func (close Close) GetRequestID() model.RequestID

GetRequestID implemented Requested.

func (Close) String added in v0.750.0

func (close Close) String() string

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 added in v0.750.0

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 added in v0.750.0

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 added in v0.750.0

func (create Create) GetRequestID() model.RequestID

GetRequestID implemented Requested.

func (Create) String

func (create Create) String() string

type CustomSearchMethod added in v0.750.0

type CustomSearchMethod interface {
	// contains filtered or unexported methods
}

CustomSearchMethod is the interface for the custom search method.

type EventsWatcher added in v0.750.0

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 added in v0.750.0

type Operation interface{}

Operation represents the base interface for possible operations that a search method can return.

type OperationList added in v0.750.0

type OperationList []Operation

OperationList is []Operation that handles marshaling and unmarshaling heterogeneous operations to and from their correct underlying types.

func (OperationList) MarshalJSON added in v0.750.0

func (l OperationList) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*OperationList) UnmarshalJSON added in v0.750.0

func (l *OperationList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OperationType added in v0.750.0

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 added in v0.750.0

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 added in v0.750.0

type Requested interface {
	GetRequestID() model.RequestID
}

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 added in v0.750.0

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 added in v0.750.0

func (s *Searcher) InitialOperations() ([]Operation, error)

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) Progress

func (s *Searcher) Progress() float64

Progress returns experiment progress as a float between 0.0 and 1.0.

func (*Searcher) Record

func (s *Searcher) Record(ops []Operation)

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 added in v0.750.0

func (s *Searcher) SetCustomSearcherProgress(progress float64) error

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 added in v0.750.0

func (s *Searcher) TrialClosed(requestID model.RequestID) ([]Operation, error)

TrialClosed informs the searcher that the trial has been closed as a result of a Close operation.

func (*Searcher) TrialCreated

func (s *Searcher) TrialCreated(requestID model.RequestID) ([]Operation, error)

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

func (s *Searcher) TrialIsClosed(requestID model.RequestID) bool

TrialIsClosed returns true if the close has been recorded with a TrialClosed call.

func (*Searcher) TrialIsCreated

func (s *Searcher) TrialIsCreated(requestID model.RequestID) bool

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 added in v0.750.0

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 added in v0.750.0

func (q *SearcherEventQueue) Enqueue(event *experimentv1.SearcherEvent)

Enqueue adds an event to the queue, setting its ID automatically.

func (*SearcherEventQueue) GetEvents added in v0.750.0

func (q *SearcherEventQueue) GetEvents() []*experimentv1.SearcherEvent

GetEvents returns all the events.

func (*SearcherEventQueue) MarshalJSON added in v0.750.0

func (q *SearcherEventQueue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*SearcherEventQueue) RemoveUpTo added in v0.750.0

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 added in v0.750.0

func (q *SearcherEventQueue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*SearcherEventQueue) Unwatch added in v0.750.0

func (q *SearcherEventQueue) Unwatch(id uuid.UUID)

Unwatch unregisters an eventsWatcher.

func (*SearcherEventQueue) Watch added in v0.750.0

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 added in v0.750.0

type SetSearcherProgress struct {
	Progress float64
}

SetSearcherProgress sets the progress of the custom searcher.

func SetSearcherProgressFromProto added in v0.750.0

func SetSearcherProgressFromProto(
	op *experimentv1.SearcherOperation_SetSearcherProgress,
) SetSearcherProgress

SetSearcherProgressFromProto creates a SetSearcherProgress from its protobuf representation.

type Shutdown

type Shutdown struct {
	Cancel  bool
	Failure bool
}

Shutdown marks the searcher as completed.

func NewShutdown added in v0.750.0

func NewShutdown() Shutdown

NewShutdown initializes a Shutdown operation for the searcher.

func ShutdownFromProto added in v0.750.0

func ShutdownFromProto(
	op *experimentv1.SearcherOperation_ShutDown,
) (*Shutdown, error)

ShutdownFromProto creates a Shutdown from its protobuf representation.

func (Shutdown) String

func (shutdown Shutdown) String() string

type Simulation added in v0.750.0

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 added in v0.750.0

type SimulationResults map[model.RequestID][]ValidateAfter

SimulationResults holds all created trials and all executed workloads for each trial.

func (SimulationResults) MarshalJSON added in v0.750.0

func (s SimulationResults) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

type ValidateAfter added in v0.750.0

type ValidateAfter struct {
	RequestID model.RequestID
	Length    uint64
}

ValidateAfter is an operation emitted by search methods to signal the trial train until its total batches trained equals the specified length.

func NewValidateAfter added in v0.750.0

func NewValidateAfter(requestID model.RequestID, length uint64) ValidateAfter

NewValidateAfter returns a new train operation.

func ValidateAfterFromProto added in v0.750.0

func ValidateAfterFromProto(
	op *experimentv1.TrialOperation_ValidateAfter,
) (*ValidateAfter, error)

ValidateAfterFromProto creates a ValidateAfter operation from its protobuf representation.

func (ValidateAfter) GetRequestID added in v0.750.0

func (t ValidateAfter) GetRequestID() model.RequestID

GetRequestID implemented Requested.

func (ValidateAfter) String added in v0.750.0

func (t ValidateAfter) String() string

func (ValidateAfter) ToProto added in v0.750.0

ToProto converts a searcher.ValidateAfter to its protobuf representation.

type ValidationFunction added in v0.750.0

type ValidationFunction func(random *rand.Rand, trialID, idx int) float64

ValidationFunction calculates the validation metric for the validation step.

Jump to

Keyboard shortcuts

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