Enable dynamic nnodes override in flytekit#3
Open
jld-adriano wants to merge 1 commit intomasterfrom
Open
Conversation
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: adriano <adriano@exa.ai>
cab91fd to
42ec508
Compare
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.
Why are the changes needed?
This PR addresses the user's need to dynamically override the number of nodes (
nnodes) for PyTorch tasks at runtime. Previously, theworker_replicascount for a PyTorchJob was fixed at task registration, preventing a single registered task from switching between single-pod and multi-node execution modes via runtime overrides.This change enables the backend to adjust the PyTorchJob's replica count based on environment variables, allowing a task registered for multi-node execution to effectively run as a single-pod job (master only) when overridden.
What changes were proposed in this pull request?
This pull request proposes changes to
flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch.goto introduce runtime overrides for PyTorchJob worker replicas and elastic policy.Specifically:
BuildResourcemethod now inspects environment variables fromTaskExecutionMetadata.PET_NNODESis set, it parses the value (single integer or "min:max" range) to dynamically adjust:worker_replicas(setting to 0 for single-node overrides, i.e.,PET_NNODES=1).MinReplicas,MaxReplicas, andReplicasin theElasticPolicy.FLYTE_PYTORCH_WORKERSis set, it explicitly overrides theworker_replicasand, for elastic jobs, also setsMaxReplicas(clampingMinReplicasif necessary).This allows a PyTorch task registered as a
pytorchtype to dynamically switch its replica configuration at launch time.How was this patch tested?
The patch was tested by successfully compiling the affected package using
go build ./....Further unit tests covering the new override logic should be added.
Labels
Setup process
Not applicable for this backend change.
Screenshots
Not applicable.
Check all the applicable boxes
Related PRs
Docs link
Slack Thread