<#6238 [Core feature] Enable gang scheduling on GK...
# flyte-github
a
#6238 [Core feature] Enable gang scheduling on GKE with Kueue by allowing to set metadata on distributed job resources Issue created by fg91 Motivation: Why do you think this is important? When executing distributed jobs like ML training jobs using e.g.
task_config=Elastic/PyTorch/TfJob/RayJobConfig/...
, it is important that all worker pods start (roughly) at the same time, in particular when GPU nodes are used. If this is not the case, at the example of distributed pytorch training, the workers starting earlier might experience timeout errors if other workers take to long to join the worker group. Even worse, if the total number of GPU nodes is constrained, multiple distributed jobs might each allocate a subset of the GPU nodes without a single distributed job being able to start its training. Today, Flyte doesn't have a good integration to allow gang scheduling of distributed jobs. Goal: What should the final outcome look like, ideally? I would like to be able to set job annotations on distributed job task configs like this ... @task( task_config=PyTorch( num_workers=..., ... # Proposed addition: metadata=ObjectMeta( annotations={"kueue.x-k8s.io/queue-name": "queue-name"}, labels={...} ) ) ) ... with the same syntax used for other distributed task types like
Elastic
,
TfJob
,
MpiJob
,
RayJobConfig
, ... In addition, I would like flytepropeller (i.e. flyteplugins) to interpret suspended jobs as "Queued". This is already the case for the kubeflow jobs and was implemented for ray in this PR. This is everything that would be needed to gang schedule distributed tasks in a workflow. The benefits of integrating with Kueue this way are • very general concept, nothing Kueue specific, might be reusable for other K8s integrations which target workloads only via metadata • significantly more lightweight integration than what has proposed e.g. here • Same syntax possible and sensible for all distributed task plugins, even the ones not supported by Kueue (but potentially by other integrations using annotations) --- On GKE, gang scheduling then works the following way: • One creates a node pool with "queued provisioning" enabled (e.g. with terraform
google_container_node_pool
by setting
queued_provisioning = "true"
and
consume_reservation_type = "NO_RESVERATION"
) • Creating the required Kueue resources as explained in the GKE documentation on dynamic workload provisioning:
ResourceFlavor
,
AdmissionCheck
,
ProvisioningRequestConfig
,
ClusterQueue
, and
LocalQueue
(in the flyte namespaces). Setting the name of the local queue in the `task_config`'s proposed
metadata
causes Kueue to suspend the Job. For e.g. pytorch tasks, flytepropeller correctly interpretes this as "Queued" phase. Kueue then creates a so-called
ProvisioningRequest
object which tells the cluster auto-scaler which kinds of resources one requests. Earlier, when we created the
ProvisioningRequestConfig
here, we specified
provisioningClassName: queued-provisioning.gke.io
. GKE's cluster autoscaler will try to fulfill the resource provisioning requests and scale up the requested nodes all at once. Only the job for which the provisioning request was created can be scheduled on these nodes. Once the job completes, these nodes are shutdown and cannot be reused by other tasks. On GKE, nodes provisioned this way are limited to a max runtime of 7 days. --- While for GKE users, this integration is an attractive way to do gang scheduling that is well integrated into the cluster autoscaler/cloud provider. Furthermore, other users might want to use Kueue for different purposes (as an actual queue), and even other users might set labels/annotations on distributed job custom resources for completely different purposes. Describe alternatives you've considered Other schedulers/queue frameworks: • In the K8s plugin configuration guide, we explain how to install scheduler plugins and Yunikorn At least the scheduler plugins unfortunately isn't a good enough solution in our experience because this scheduler can starve schedulable pods if too many unschedulable pods exist (see issue). • There have been attempts to integrate Yunikorn and Kueue more deeply into flytepropeller which weren't accepted though • There have been discussions in Slack about using Kueue, suggesting to use e.g.
pyflyte run --labels/--annotations
to set the required metadata for Kueue. However, this is not good enough because this applies the metadata to all nodes in the graph while you might want to do gang scheduling only for a subset. Other ways to expose annotations (and labels) on the task level: • Add task kwargs for labels and annotations: def task( # If we added these args ... labels={...}, annotations={...), # ... for simple python function tasks this would conflict with this existing : pod_template=PodTemplate(annotations=...) ) • We could just apply the annotations (and labels) set in
pod_template=PodTemplate
to distributed job objects like
PyTorchJob
as well. However, from a K8s perspective, this feels very wrong. Propose: Link/Inline OR Additional context No response Are you sure this issue hasn't been raised already? • Yes Have you read the Code of Conduct? • Yes flyteorg/flyte