-
Notifications
You must be signed in to change notification settings - Fork 443
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
base: master
Are you sure you want to change the base?
[GSOC] hyperopt
suggestion service logic update
#2412
Conversation
Signed-off-by: Shashank Mittal <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/area gsoc |
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
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.
1a7a831
to
fddb763
Compare
Signed-off-by: Shashank Mittal <[email protected]> validation fix add e2e tests for hyperopt added e2e test to workflow
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]> sigma calculation fixed fix parse new arguments to mnist.py
fddb763
to
282f81d
Compare
) | ||
elif param.distribution == api_pb2.NORMAL: | ||
mu = (float(param.min) + float(param.max)) / 2 | ||
sigma = (float(param.max) - float(param.min)) / 6 |
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.
I followed this article to determine the value of sigma
from min
and max
.
cc @tenzen-y @andreyvelich
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.
Maybe we should add this article to the comments. WDYT @tenzen-y @johnugeorge ?
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.
I do not want to depend on the individual article. Instead of that, it would be better to add an actual mathematical description here as a comment.
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
@tenzen-y I have added two new parameters, |
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
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.
|
Co-authored-by: Yuki Iwai <[email protected]> Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
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
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
a1156fc
to
658daaf
Compare
… specified Signed-off-by: Shashank Mittal <[email protected]>
) | ||
elif param.distribution == api_pb2.NORMAL: | ||
mu = (float(param.min) + float(param.max)) / 2 | ||
sigma = (float(param.max) - float(param.min)) / 6 |
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.
Maybe we should add this article to the comments. WDYT @tenzen-y @johnugeorge ?
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
Signed-off-by: Shashank Mittal <[email protected]>
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: