refactor(runtime): Migrate metahyper to neps.runtime
#71
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.
This is a semi-large PR but the main change was to integrate meta-hyper to just be part of
neps
. As such, I renamed it to just beneps/runtime.py
.Here's a synopsis that included at the top of the file:
Some major points about the
runtime.py
:tblogger
. I tried to make this more explicit and a runtime api that is allowed to be used through neps. This could be useful in simplifying user API, as shown in the below example. In this way, we do not need to inject anything into the function signature itself, preventing backwards breaking compatibility when wanting to add new features, as well as providing a simple access point for all features we can provide for a user in a given trial. Discussed with @Neeratyoyread()
which would load in the configs and results. This now needs to be explicitly done with theSharedState
which better indicates what it actually requires to read, as well as requiring an explicit declaration of locking the shared state, such that it's evident it's not a cheap operation and that it may also cause blocks.Trial
is mostly for booking inside ofruntime
and does not leek into the reset of NePS, however it might be useful that optimizers are aware of it as it contains more information than just theConfigResult
While doing so there are quite a few minor changes made other than code structure:
Sampler
abstraction, it was only used byBaseSampler
. Moved allSampler
methods intoBaseSampler
def load_results(..., evaluating: dict[str, SearchSpace])
previously statedpending_evaluations: dict[str, ConfigResult]
which was incorrect.YamlSerializer
class. There's now just aserialize()
anddeserialize()
function which does the same thing. The automatic config transformations it was doing usingsampler.load_config()
inside it'sdeserialize()
was removed and just done explicitly on the result ofdeserialize()
.pylint
isort
andblack
and just replaced withruff
alone.neps/types.py
file for commonly used simple types. I would hope to remove the string and dict typing that exists in a lot of places as it becomes very unmaintainable at some point. (SMAC had a lot of silent issues due to this)_Locker
to accept arguments such as timeout and polling. There's also an environment variable that can be used to control this if really required. The biggest change is that all operations are done with awith
block to prevent possibilities of accidentally not unlocking. This also handles cases where exceptions might get thrown in the block. As side note, the locking time is not really what hurts NePS in hpo benchmarking with cheap evaluations, although lower locking certainly does help. Turns out the serialization is the slowest part as described further in [Optim] Consider pickle for optimizer state file in run (with option to toggle) #64