fix(trainer): unpack train_func_parameters as kwargs in localprocess backend - #769
Open
SahilKumar75 wants to merge 1 commit into
Open
fix(trainer): unpack train_func_parameters as kwargs in localprocess backend#769SahilKumar75 wants to merge 1 commit into
SahilKumar75 wants to merge 1 commit into
Conversation
…backend The LocalProcess backend embedded train_func_parameters as a single positional dict argument instead of unpacking it as keyword arguments, unlike the Kubernetes backend which already does this correctly. Any CustomTrainer using func_args with LocalProcessBackend would fail with a TypeError since the training function receives one dict positional argument instead of its named parameters. Signed-off-by: Sahil Kumar Singh <60318530+SahilKumar75@users.noreply.github.com>
Contributor
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
The required checks are passing. Could a Kubeflow approver please review this change and add LGTM if it is ready? |
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.
What happened?
The LocalProcess backend generates the training function call by embedding train_func_parameters directly into the generated script as a single positional argument:
Since train_func_parameters is a dict, this produces a call like train_func({'lr': 0.01, 'num_epochs': 5}) instead of train_func(lr=0.01, num_epochs=5). Any training function that takes named parameters raises a TypeError as soon as it is run through LocalProcessBackend.
The Kubernetes backend already handles this correctly with double star unpacking:
What did you expect to happen?
CustomTrainer func_args should be passed as keyword arguments on the LocalProcess backend too, consistent with the Kubernetes backend.
Fix
Apply the same ** unpacking used by the Kubernetes backend to the LocalProcess backend's generated call. Added kubeflow/trainer/backends/localprocess/utils_test.py (did not previously exist) covering both the parameterized and no argument cases, asserting the generated script is valid, executable Python.
make test-python and make verify pass locally.