Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Replaces the shallow
kwargs.update(sampled_hyperparams)in the Optunaobjective()with a recursive
deep_update()that merges nested dicts key-by-key instead ofreplacing them wholesale. Implemented as a local helper (the issue suggested pydantic's
deep_update; a local function avoids adding a dependency for one utility).The helper deep-copies the base dict, which also fixes a latent leak: the previous
self._hyperparams.copy()was shallow, so nested dicts were shared across trials.Motivation and Context
Fixes #431. The hyperparameter samplers return nested dicts (e.g.
{"policy_kwargs": {"net_arch": ..., "activation_fn": ...}}). The olddict.update()replaced the entire user-specified
policy_kwargs, silently dropping keys likefeatures_extractor_class/features_extractor_kwargsrequired for custom policies(the reporter observed NaN actions as a result).
Note:
read_hyperparameters()applies study hyperparameters fromload_trial()(
--trial-id) via the same shallowupdate()pattern and has the same issue — happyto send a follow-up PR for that path if this approach is approved.
Types of changes
Checklist:
make check-codestyleandmake lint(CI)make pytestandmake typeboth pass (CI)AI assistance disclosure: I used AI assistance to draft parts of this change.
I have reviewed and understood every modified line and can explain the reasoning.