feat: import pre-evaluated trials #244
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces a new public API, neps.import_trials, allowing users to import pre-evaluated configurations into an optimization run. This enables "warm-starting" an optimization using results from external sources, such as a previous random search or another HPO algorithm.
Motivation
Currently, neps primarily supports continuing an optimization from trials it generated itself. However, a common use case is to leverage existing data from prior experiments to guide a new, more advanced optimization process. For example, a user might want to use a set of randomly evaluated configurations as the initial design for a Bayesian Optimization run.
This feature addresses that gap by providing a formal, validated way to inject external data into the pipeline.
Implementation Details
New Public API: A new function, neps.import_trials, has been added to neps/api.py. This function serves as the high-level entry point for users.
Optimizer-Specific Logic: The top-level API function delegates the core import logic to the specific optimizer instance being used. This ensures that each optimizer can handle validation and state integration according to its unique requirements (e.g., handling fidelities for PriMO, creating rung IDs for bracket-based optimizers, etc.).
For Optimizer Developers
To support this feature, all optimizer classes must now implement an import_trials method. This method is responsible for:
Validating that the provided configurations and results are compatible with the optimizer's search space and requirements.
Correctly formatting the data and integrating it into the optimizer's internal state.
Usage Example