Skip to content
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

fix nproc env in elastic mode for pytorchjob #1948

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/controller.v1/pytorch/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ func setPodEnv(obj interface{}, podTemplateSpec *corev1.PodTemplateSpec, rtype,
Name: "RANK",
Value: strconv.Itoa(rank),
})
podTemplateSpec.Spec.Containers[i].Env = append(podTemplateSpec.Spec.Containers[i].Env, corev1.EnvVar{
Name: EnvNprocPerNode,
Value: *pytorchjob.Spec.NprocPerNode,
})
podTemplateSpec.Spec.Containers[i].Env = append(podTemplateSpec.Spec.Containers[i].Env, corev1.EnvVar{
Name: EnvNodeRank,
Value: strconv.Itoa(rank),
})
}

if pytorchjob.Spec.NprocPerNode != nil {
podTemplateSpec.Spec.Containers[i].Env = append(podTemplateSpec.Spec.Containers[i].Env, corev1.EnvVar{
Name: EnvNprocPerNode,
Value: *pytorchjob.Spec.NprocPerNode,
})
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change removes the necessity to add master spec to run multiple processes per pod using python/torchrun launch method without the elastic spec in the yaml, but doesn't solve #1947

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to solve #1947 I think we need to make changes here

if elasticPolicy.NProcPerNode != nil {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepanker13 elastic.go has env vars when elastic policy is set. As per the original issue, it works correctly when elasticPolicy.NProcPerNode is set.

Copy link
Contributor

@deepanker13 deepanker13 Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnugeorge following this pr #1840 , I raised issue #1947 which when implemented should complete the point striked out in the below screenshot
Screenshot 2023-11-20 at 11 37 10 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to solve #1947 I think we need to make changes here

if elasticPolicy.NProcPerNode != nil {

No. this part will be deprecated. We should touch the global one.

// Set the elastic environment variables if the elasticPolicy is not null.
// nnodes is set in range format in elastic mode, e.g. nnodes=1:4
// otherwise, nnodes is set by int, e.g. nnodes=2
Expand Down