-
Notifications
You must be signed in to change notification settings - Fork 458
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] optuna
suggestion service logic update
#2446
Changes from all commits
d4ae140
99ecbcd
fd460b6
6b18e9b
2c56864
7bbfc50
49065a5
d775c23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
apiVersion: kubeflow.org/v1beta1 | ||
kind: Experiment | ||
metadata: | ||
namespace: kubeflow | ||
name: optuna-distribution | ||
spec: | ||
objective: | ||
type: minimize | ||
goal: 0.05 | ||
objectiveMetricName: loss | ||
algorithm: | ||
algorithmName: tpe | ||
parallelTrialCount: 3 | ||
maxTrialCount: 12 | ||
maxFailedTrialCount: 3 | ||
parameters: | ||
- name: lr | ||
parameterType: double | ||
feasibleSpace: | ||
min: "1" | ||
max: "5" | ||
step: "0.1" | ||
distribution: uniform | ||
- name: momentum | ||
parameterType: double | ||
feasibleSpace: | ||
min: "0.001" | ||
max: "3" | ||
distribution: logUniform | ||
- name: epochs | ||
parameterType: int | ||
feasibleSpace: | ||
min: "1" | ||
max: "3" | ||
distribution: uniform | ||
- name: batch_size | ||
parameterType: int | ||
feasibleSpace: | ||
min: "32" | ||
max: "64" | ||
distribution: logUniform | ||
trialTemplate: | ||
primaryContainerName: training-container | ||
trialParameters: | ||
- name: learningRate | ||
description: Learning rate for the training model | ||
reference: lr | ||
- name: momentum | ||
description: Momentum for the training model | ||
reference: momentum | ||
- name: epochs | ||
description: Epochs | ||
reference: epochs | ||
- name: batchSize | ||
description: Batch Size | ||
reference: batch_size | ||
trialSpec: | ||
apiVersion: batch/v1 | ||
kind: Job | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: training-container | ||
image: docker.io/kubeflowkatib/pytorch-mnist-cpu:latest | ||
command: | ||
- "python3" | ||
- "/opt/pytorch-mnist/mnist.py" | ||
- "--epochs=${trialParameters.epochs}" | ||
- "--batch-size=${trialParameters.batchSize}" | ||
- "--lr=${trialParameters.learningRate}" | ||
- "--momentum=${trialParameters.momentum}" | ||
restartPolicy: Never |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -50,7 +50,7 @@ def setup_method(self): | |||||||||||||||||||||
], | ||||||||||||||||||||||
["cmaes", {"restart_strategy": "ipop", "sigma": "2", "random_state": "71"}], | ||||||||||||||||||||||
["random", {"random_state": "71"}], | ||||||||||||||||||||||
["grid", {"random_state": "71"}], | ||||||||||||||||||||||
# ["grid", {"random_state": "71"}], | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mahdikhashan @andreyvelich The unit tests are failing for this grid algorithm setting for katib/pkg/suggestion/v1beta1/internal/search_space.py Lines 57 to 62 in 3e736dc
katib/pkg/suggestion/v1beta1/optuna/base_service.py Lines 56 to 59 in 3e736dc
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to explicitly check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can look into this tomorrow in early morning, hope its fine with you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems, to my current understanding of Optuna docs, that for grid algo, we need to have step defined. I'll investigate further with setting step and the second error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I could not figure out where we can change to handle it - will try to dig deeper later. |
||||||||||||||||||||||
], | ||||||||||||||||||||||
) | ||||||||||||||||||||||
def test_get_suggestion(self, algorithm_name, algorithm_settings): | ||||||||||||||||||||||
|
@@ -95,6 +95,62 @@ def test_get_suggestion(self, algorithm_name, algorithm_settings): | |||||||||||||||||||||
max="5", min="1", step="1", list=[] | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-5", | ||||||||||||||||||||||
parameter_type=api_pb2.INT, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", step="2", distribution=api_pb2.UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-6", | ||||||||||||||||||||||
parameter_type=api_pb2.INT, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", distribution=api_pb2.UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-7", | ||||||||||||||||||||||
parameter_type=api_pb2.INT, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", step="2", distribution=api_pb2.LOG_UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-8", | ||||||||||||||||||||||
parameter_type=api_pb2.INT, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", distribution=api_pb2.LOG_UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-9", | ||||||||||||||||||||||
parameter_type=api_pb2.DOUBLE, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="11", min="1", step="2.5", distribution=api_pb2.UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-10", | ||||||||||||||||||||||
parameter_type=api_pb2.DOUBLE, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="11", min="1", step="2.5", distribution=api_pb2.LOG_UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-11", | ||||||||||||||||||||||
parameter_type=api_pb2.DOUBLE, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", distribution=api_pb2.UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
api_pb2.ParameterSpec( | ||||||||||||||||||||||
name="param-12", | ||||||||||||||||||||||
parameter_type=api_pb2.DOUBLE, | ||||||||||||||||||||||
feasible_space=api_pb2.FeasibleSpace( | ||||||||||||||||||||||
max="5", min="1", distribution=api_pb2.LOG_UNIFORM | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
] | ||||||||||||||||||||||
), | ||||||||||||||||||||||
), | ||||||||||||||||||||||
|
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.
Would this always be equal to 1 since values are always
int
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.
Not always. The condition ensures that low is at least 1, which is required for
log
distributions. It prevents invalid cases where param.min could be 0 or negative.As specified in the optuna documentation, If
log
isTrue
,low
must be larger than or equal to 1.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.
Oh, you are right.