searcher

package
v0.38.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

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

Action is an action that a searcher would like to perform.

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"`
}

Create is a directive from the searcher to create a new run.

func NewCreate

func NewCreate(
	rand *nprand.State, s HParamSample,
) Create

NewCreate initializes a new Create operation with a new request ID and the given hyperparameters.

func (Create) String

func (action Create) String() string

type HParamSample

type HParamSample map[string]interface{}

HParamSample is a sampling of the hyperparameters for a model.

type PartialUnits

type PartialUnits float64

PartialUnits represent partial epochs, batches or records where the Unit is implied.

type SearchMethod

type SearchMethod interface {

	// TODO: refactor as model.Snapshotter interface or something
	model.Snapshotter
	Type() SearchMethodType
	// contains filtered or unexported methods
}

SearchMethod is the interface for hyperparameter 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"
	// ASHASearch is the SearchMethodType for an ASHA searcher.
	ASHASearch SearchMethodType = "asha"
	// AdaptiveASHASearch is the SearchMethodType for an adaptive ASHA searcher.
	AdaptiveASHASearch SearchMethodType = "adaptive_asha"
)

type SearchSummary

type SearchSummary struct {
	Trials []TrialSummary
	Config expconf.SearcherConfig
}

SearchSummary describes a summary of planned trials and the associated expconf.SearcherConfig.

func Simulate

Simulate generates the intended training plan for the searcher.

func (SearchSummary) Proto

Proto converts the SearchSummary to its protobuf representation.

type SearchUnit

type SearchUnit struct {
	Name      *string
	Value     *int32
	MaxLength bool
}

SearchUnit is a length unit. If MaxLength is true, Name and Value will be ignored.

func (SearchUnit) Proto

func (su SearchUnit) Proto() *experimentv1.SearchUnit

Proto converts the SearchUnit to its protobuf representation.

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

func (s *Searcher) InitialTrials() ([]Action, error)

InitialTrials returns the initial trials the searcher intends to create at the start of a search. 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 []Action)

Record records actions 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) SetTrialProgress

func (s *Searcher) SetTrialProgress(requestID model.RequestID, progress float64)

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

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

TrialCreated informs the searcher that a new trial has been created.

func (*Searcher) TrialExited

func (s *Searcher) TrialExited(requestID model.RequestID) ([]Action, error)

TrialExited informs the searcher that a trial has exited.

func (*Searcher) TrialExitedEarly

func (s *Searcher) TrialExitedEarly(
	requestID model.RequestID, exitedReason model.ExitedReason,
) ([]Action, error)

TrialExitedEarly informs the searcher that a trial has exited early.

func (*Searcher) TrialIsClosed

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

TrialIsClosed returns true if the close has been recorded with a TrialExited 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, metrics map[string]interface{},
) ([]Action, error)

ValidationCompleted informs the searcher that a validation for the trial was completed.

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]float64 `json:"trial_progress"`

	Rand *nprand.State `json:"rand"`

	SearchMethodState json.RawMessage `json:"search_method_state"`
}

SearcherState encapsulates all persisted searcher state.

type Shutdown

type Shutdown struct {
	Cancel  bool
	Failure bool
}

Shutdown marks the searcher as completed.

func (Shutdown) String

func (shutdown Shutdown) String() string

type Stop

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

Stop is a directive from the searcher to stop a run.

func NewStop

func NewStop(requestID model.RequestID) Stop

NewStop initializes a new Stop action with the given Run ID.

func (Stop) String

func (action Stop) String() string

type TrialSummary

type TrialSummary struct {
	Count int
	Unit  SearchUnit
}

TrialSummary is a summary of the number of trials that will train for Unit length.

func (TrialSummary) Proto

Proto converts the TrialSummary to its protobuf representation.

Jump to

Keyboard shortcuts

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