-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GSOC] hyperopt
suggestion service logic update
#2412
[GSOC] hyperopt
suggestion service logic update
#2412
Conversation
/area gsoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this @shashank-iitbhu!
I left a few comments
pkg/apis/manager/v1beta1/api.proto
Outdated
NORMAL = 2; | ||
LOG_NORMAL = 3; | ||
DISTRIBUTION_UNKNOWN = 4; | ||
DISTRIBUTION_UNKNOWN = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the same name as for parameter_type
DISTRIBUTION_UNKNOWN = 0; | |
UNKNOWN_DISTRIBUTION = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DISTRIBUTION_UNKNOWN = 0; | |
DISTRIBUTION _UNSPECIFIED = 0; |
I would like to select the UNSPECIFIED
suffix here.
Please see: https://google.aip.dev/126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, @tenzen-y should we rename other gRPC parameters to UNSPECIFIED ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing released gRPC, it indicates losing backward compatibility.
So, I would like to keep using the existing API for released protocolbuffers API, @andreyvelich WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these gRPC APIs are not exposed to the end-users, do you still think that we should not change the existing APIs ?
It only affects users who build their own Suggestion service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these gRPC APIs are not exposed to the end-users, do you still think that we should not change the existing APIs ?
Almost correct. Additionally, when users keep using the removed Suggestion Services like the Chocolate Suggestion, users face the same problem.
So, can we collect feedback on the dedicated issue outside of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let's followup on this in the issue, and rename it after few months if we don't get any feedback.
@shashank-iitbhu Please can you create an issue to track it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let's followup on this in the issue, and rename it after few months if we don't get any feedback. @shashank-iitbhu Please can you create an issue to track it ?
Sure, I will create a separate issue to track the renaming of other gRPC parameters to UNSPECIFIED.
pkg/controller.v1beta1/suggestion/suggestionclient/suggestionclient.go
Outdated
Show resolved
Hide resolved
) | ||
elif param.type == DOUBLE: | ||
hyperopt_search_space[param.name] = hyperopt.hp.uniform( | ||
hyperopt_search_space[param.name] = hyperopt.hp.uniformint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If parameter is int, why we can't support other distributions like lognormal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Distributions like uniform
quniform
loguniform
normal
etc return float values. They are designed to sample from a range of values that can take any real number (float), which might not make sense if we're looking for an integer value.
Although we can definitely add support for these distributions when parameter is int
also. Should we do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tenzen-y @kubeflow/wg-training-leads @shashank-iitbhu Should we round this float
value to int
if user wants to use this distribution and int parameter type ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tenzen-y @kubeflow/wg-training-leads @shashank-iitbhu Should we round this float value to int if user wants to use this distribution and int parameter type ?
SGTM
Users can specify the double parameter type if they want to compute more exactly.
But, documentation of this restriction for int parameter type would be better.
fddb763
to
282f81d
Compare
@tenzen-y I have added two new parameters, |
katib/pkg/suggestion/v1beta1/hyperopt/base_service.py Lines 265 to 266 in 867c40a
here the float values sampled from the distribution get converted to int for INT parameter type.
|
log_min = math.log(float(param.min)) | ||
log_max = math.log(float(param.max)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use the fixed value when the min and max are scalers the same as Nevergrad, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can, but that was an edge case when min
and max
are not defined in case of nevergrad.
elif isinstance(param, (p.Log, p.Scalar)):
if (param.bounds[0][0] is None) or (param.bounds[1][0] is None):
if isinstance(param, p.Scalar) and not param.integer:
return hp.lognormal(label=param_name, mu=0, sigma=1)
For example,
- name: batch_size
parameterType: int
feasibleSpace:
min: "32"
max: "64"
distribution: "logNormal"
The above parameter will be sampled out from this graph:
where u=3.8123
and sigma=0.3465
are calculated by putting min=32
and max=64
in our code. and E(X)
represents the mean which is 48
in our case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense.
In that case, could you address the cases where min or max is not specified, as well as nevergrad?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shashank-iitbhu This is still pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
katib/pkg/webhook/v1beta1/experiment/validator/validator.go
Lines 287 to 290 in 867c40a
if param.FeasibleSpace.Max == "" && param.FeasibleSpace.Min == "" { | |
allErrs = append(allErrs, field.Required(parametersPath.Index(i).Child("feasibleSpace").Child("max"), | |
fmt.Sprintf("feasibleSpace.max or feasibleSpace.min must be specified for parameterType: %v", param.ParameterType))) | |
} |
The webhook validator requires feasibleSpace.max
or feasibleSpace.min
to be specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But when either min or max is empty, this validation does not reject the request, right?
So, shouldn't we implement the special case in the Suggestion Service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the validation webhook does not reject the request when either min or max is empty. But I created an example where:
- name: batch_size
parameterType: int
feasibleSpace:
min: "32"
distribution: "logNormal"
For this, the experiment is being created but the suggestion service is not sampling out any value hence the trials are not running, though handled this case (when either min or max are not specified) in pkg/suggestion/v1beta1/hyperopt/base_service.py
.
Do we need to check experiment_defaults.go
file?
https://github.com/kubeflow/katib/blob/867c40a1b0669446c774cd6e770a5b7bbf1eb2f1/pkg/apis/controller/experiments/v1beta1/experiment_defaults.go
a1156fc
to
658daaf
Compare
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> sigma calculation fixed fix parse new arguments to mnist.py
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com> Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
… specified Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in>
494f41e
to
4fc897d
Compare
Thanks for this great contribution @shashank-iitbhu! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andreyvelich The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* resolved merge conflicts Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * fix Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * DISTRIBUTION_UNKNOWN enum set to 0 in gRPC api Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * convert parameter method fix Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> validation fix add e2e tests for hyperopt added e2e test to workflow * convert feasibleSpace func updated Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * renamed DISTRIBUTION_UNKNOWN to DISTRIBUTION_UNSPECIFIED Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * fix Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added more test cases for hyperopt distributions Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added support for NORMAL and LOG_NORMAL in hyperopt suggestion service Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added e2e tests for NORMAL and LOG_NORMAL Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> sigma calculation fixed fix parse new arguments to mnist.py * hyperopt-suggestion example update Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * updated logic for log distributions Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * updated logic for log distributions Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * e2e test fixed Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added support for parameter distributions for Parameter type INT Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * unit test fixed Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * Update pkg/suggestion/v1beta1/hyperopt/base_service.py Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com> Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * comment fixed Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added unit tests for INT parameter type Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * completed param unit test cases Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * handled default case for normal distributions when min or max are not specified Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * fixed validation logic for min and max Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * removed unnecessary test params Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * fixes Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * added comments Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * fix Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * set default distribution as uniform Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * line omit Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> * removed empty spaces from yaml files Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> --------- Signed-off-by: Shashank Mittal <shashank.mittal.mec22@itbhu.ac.in> Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com> Signed-off-by: Gary Miguel <garymm@garymm.org>
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2374
Checklist: