acoustic-carpenter-78188
07/19/2023, 2:02 PM@task(
task_config=Elastic(
nnodes=2,
nproc_per_node=2,
),
requests=Resources(cpu="1", mem="1Gi", gpu="1"),
)
def train():
...
This PR fixes this.
Type
☑︎ Bug Fix
☐ Feature
☐ Plugin
Are all requirements met?
☑︎ Code completed
☑︎ Smoke tested
☑︎ Unit tests added
☐ Code documentation added
☑︎ Any pending items have an associated Issue
Complete description
The kubeflow plugin was recently refactored in flytekit (flyteorg/flytekit#1627) as well as in flyteplugins (#345).
After the refactoring, users can set e.g. different resources for master and worker replicas of PyTorch tasks:
@task(
task_config=PyTorch(
worker=Worker(
requests=Resources(cpu="2", mem="2Gi"),
limits=Resources(cpu="4", mem="2Gi"),
),
master=...
)
requests=Resources(cpu="1", mem="1Gi", gpu="1"),
)
....
If the user overrides one of the resource requests in the task_config, in the backend we override the resources configured on the task level here.
Now, in a @task(task_config=PyTorch()..) task, when the user doesn't override the resources, we send task_models.Resources(requests=[], limits=[]) (which is different from None/nil, see here) to the backend as part of the worker spec. We go into this if statement but not into this one within the first. As a consequence, in this case we don't overwrite the resource request set in @task(requests=Resources()). This makes sense.
However, the Elastic task config in flytekitplugins currently doesn't allow overwriting the resource request since elastic pytorch training jobs don't have a differentiation between master and worker replicas. There are only workers which means we can simply use the normal @task(requests=Resources()) to specify their resources.
This, however, means that in this case we send None/nil to the backend as part of the worker specs resource request. Here we go into the else case and simply delete what the user set as @task(requests=Resources()).
This seems wrong and this PR changes this.
Tracking Issue
NA
fixes https://github.com/flyteorg/flyte/issues/
Follow-up issue
NA
flyteorg/flyteplugins
Codecov: 62.96% (-0.01%) compared to 13ef7d6
Codecov: 0.00% of diff hit (target 62.96%)
✅ 5 other checks have passed
5/7 successful checksacoustic-carpenter-78188
08/08/2023, 6:27 PM