-
Notifications
You must be signed in to change notification settings - Fork 712
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
Use dictionary unpacking to pass trainer function arguments #2384
base: master
Are you sure you want to change the base?
Conversation
[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 |
Signed-off-by: Antonin Stefanutti <[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.
Thanks for this @astefanutti!
f"{func_code}\n" | ||
f"kwargs={train_func_parameters}\n" | ||
f"{train_func.__name__}(**kwargs)\n" | ||
) |
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.
What advantages do you see to pass func args via kwargs to the function compare to existing execution ?
I guess, user makes it more explicit what parameters are passed to the Training Function compare to passing parameters
dict, 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.
What do you think about this approach @droctothorpe @kubeflow/wg-training-leads @Electronic-Waste ?
Another idea could be to ask users to pass parameters to the function via ENVs.
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 think the existing approach has already met with the need of users. Maybe we could adopt this apporach when users claim they need 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.
What advantages do you see to pass func args via kwargs to the function compare to existing execution ?
I guess, user makes it more explicit what parameters are passed to the Training Function compare to passing parameters dict, right ?
Right, from the end-user standpoint, that changes the signature contract of the training function, so instead of writing something like:
def train_func(dict):
batch_size = dict.get("batch_size", 64)
test_batch_size = dict.get("test_batch_size", 1000)
epochs = dict.get("epochs", 10)
lr = dict.get("lr", 0.01)
gamma = dict.get("gamma", 0.7)
dry_run = dict.get("dry_run", False)
seed = dict.get("seed", 1)
save_model = dict.get("save_model", False)
# ...
Users can write:
def train_func(batch_size=64,
test_batch_size=1000,
epochs=10,
lr=0.01,
gamma=0.7,
dry_run=False,
seed=1,
log_interval=10,
save_model=False):
# ...
As a user myself in that case, I find it clearer, and fail to see any drawbacks.
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 make sense. @kubeflow/wg-training-leads @droctothorpe @deepanker13 What do you think about this approach ?
Did we try to explore how other frameworks/projects solve it ? For example, I was looking at Ray Train, and they follow similar approach with the train_loop_config
parameter.
What this PR does / why we need it:
It makes it possible to pass the training function argument unpacked, e.g.:
Which issue(s) this PR fixes (optional, in
Fixes #<issue number>, #<issue number>, ...
format, will close the issue(s) when PR gets merged):Fixes #2383
Checklist: