New RunLLM response generated: >>>*# Question* Hi...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* Hi All. I am running a distributed training job using Flyte + Kubeflow training operator as suggested by the documentation. I just added a sidecar to my pod spec. A sidecar is an init container that has restartPolicy=Always, which makes it special so that main container does not wait for the sidecar to start and pod does not need to wait for the sidecar to complete. However, when I run multi-node training with the training operator, the restartPolicy=Always for the sidecar is removed, which turns it into a regular init container and then the pod never starts as this particular sidecar is designed to run as long as the pod is running. I am trying to debug at what place the restart policy is dropped. Is this something that happens within the kfpytorch plugin or is this something that happens inside the training operator. How can I find how my pod spec is being converted into PyTorchJob? # Answer The issue you're encountering with the
restartPolicy
being removed from the sidecar container likely stems from the way the Flyte PyTorch plugin or the Kubeflow training operator handles the pod specification. To debug this, you can start by examining the Flyte PyTorch plugin's code to see how it processes and converts the pod spec into a
PyTorchJob
resource. Specifically, you should look at the
OverridePrimaryContainerName
and
ParseRestartPolicy
functions in the Flyte plugin code, as these functions handle container and restart policy configurations. Here is a relevant snippet from the Flyte plugin code that shows how the restart policy is parsed and applied:
Copy code
// ParseRestartPolicy converts a Flyte restart policy to a k8s restart policy.
func ParseRestartPolicy(flyteRestartPolicy kfplugins.RestartPolicy) commonOp.RestartPolicy {
    restartPolicyMap := map[kfplugins.RestartPolicy]commonOp.RestartPolicy{
        kfplugins.RestartPolicy_RESTART_POLICY_NEVER:      commonOp.RestartPolicyNever,
        kfplugins.RestartPolicy_RESTART_POLICY_ON_FAILURE: commonOp.RestartPolicyOnFailure,
        kfplugins.RestartPolicy_RESTART_POLICY_ALWAYS:     commonOp.RestartPolicyAlways,
    }
    return restartPolicyMap[flyteRestartPolicy]
}
Additionally, you can check the
OverridePrimaryContainerName
function to see if it modifies the container names or other properties:
Copy code
func OverridePrimaryContainerName(podSpec *v1.PodSpec, primaryContainerName string, defaultContainerName string) {
    for idx, c := range podSpec.Containers {
        if c.Name == primaryContainerName {
            podSpec.Containers[idx].Name = defaultContainerName
            return
        }
    }
}
To find out how your pod spec is being converted into a
PyTorchJob
, you can look at the
BuildResource
function in the Flyte plugin, which constructs the
PyTorchJob
resource from the task template and pod spec: ``` ```
>>```
res, err := pytorchResourceHandler.BuildResource(context.TODO(), dummyPytorchTaskContext(taskTemplate, resourceRequirements, nil, "")) ``` For more detailed debugging, you can add logging statements in these functions to print out the pod spec and
PyTorchJob
resource at various stages of the conversion process. Would you like more detailed guidance on how to modify or debug these specific parts of the Flyte plugin code? Sources: - https://docs.flyte.org/en/latest/_modules/flytekitplugins/kftensorflow/task.html - https://docs.flyte.org/en/latest/_modules/flytekitplugins/kfmpi/task.html Slack Link https://flyte-org.slack.com/archives/CP2HDHKE1/p1718181188.682099 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.