feat: add KubeflowExecutor for Kubeflow Training Operator (PyTorchJob + TrainJob)#462
Open
feat: add KubeflowExecutor for Kubeflow Training Operator (PyTorchJob + TrainJob)#462
Conversation
435b65c to
8f943bc
Compare
8f943bc to
9b2921d
Compare
Introduces KubeflowExecutor and a matching TorchX scheduler so users can deploy distributed training jobs to any Kubernetes cluster running the Kubeflow Training Operator via run.run() / run.Experiment. Supported job kinds (toggled via job_kind field): - PyTorchJob (Training Operator v1, kubeflow.org/v1) - TrainJob (Training Operator v2, trainer.kubeflow.org/v1alpha1) Key features: - Kubernetes config loaded automatically (local kubeconfig → in-cluster fallback) - PyTorchJob: builds Master + Worker replica specs with nprocPerNode - TrainJob: builds spec.trainer + merges all pod-level config (volumes, tolerations, affinity, imagePullSecrets, resourceClaims, etc.) into a single podTemplateOverrides entry targeting "node" - env_list field supports full env var dicts (valueFrom / secretKeyRef) - pod_spec_overrides merges arbitrary extra fields into the pod spec - launch(wait=True) polls until RUNNING / SUCCEEDED / FAILED - cancel(wait=True) polls until CR is gone and all pods are terminated - TorchX scheduler persists job state in ~/.nemo_run/.kubeflow_jobs.json and maps KubeflowJobState → AppState (UNKNOWN/None → PENDING to avoid false failures on transient API errors) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
63 tests covering: - Executor: defaults, kubeconfig fallback, nnodes, nproc_per_node resolution, assign, manifest generation for PyTorchJob and TrainJob (structure, resources, volumes, env_vars, env_list, labels, image_pull_secrets, tolerations, affinity, pod_spec_overrides, spec_kwargs, container_kwargs), launch (success, wait, timeout, conflict), status (all states + API errors), cancel (plain, 404, wait=True, wait timeout), fetch_logs (no-follow, follow, TrainJob label selector) - Scheduler: create, dryrun, schedule, describe (all states + UNKNOWN→PENDING regression), cancel, log_iter (list + str), persistence (new file, merge, missing file), state map Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
Introduces KubeflowExecutor and a matching TorchX scheduler so users can deploy distributed training jobs to any Kubernetes cluster running the Kubeflow Training Operator via run.run() / run.Experiment. Supported job kinds (toggled via job_kind field): - PyTorchJob (Training Operator v1, kubeflow.org/v1) - TrainJob (Training Operator v2, trainer.kubeflow.org/v1alpha1) Key features: - Kubernetes config loaded automatically (local kubeconfig → in-cluster fallback) - PyTorchJob: builds Master + Worker replica specs with nprocPerNode - TrainJob: builds spec.trainer + merges all pod-level config (volumes, tolerations, affinity, imagePullSecrets, resourceClaims, etc.) into a single podTemplateOverrides entry targeting "node" - env_list field supports full env var dicts (valueFrom / secretKeyRef) - pod_spec_overrides merges arbitrary extra fields into the pod spec - launch(wait=True) polls until RUNNING / SUCCEEDED / FAILED - cancel(wait=True) polls until CR is gone and all pods are terminated - TorchX scheduler persists job state in ~/.nemo_run/.kubeflow_jobs.json and maps KubeflowJobState → AppState (UNKNOWN/None → PENDING to avoid false failures on transient API errors) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
9b2921d to
6f63116
Compare
- kubernetes import wrapped in try/except; ImportError raised at instantiation time with a helpful install message - New [kubeflow] optional extra in pyproject.toml: pip install nemo-run[kubeflow] - uv.lock updated Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: oliver könig <okoenig@nvidia.com>
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.
Summary
KubeflowExecutorthat submits distributed training jobs to any Kubernetes cluster running the Kubeflow Training Operatorjob_kindtogglerun.run()andrun.ExperimentPyTorchJob vs TrainJob
kubeflow.org/v1trainer.kubeflow.org/v1alpha1podTemplateOverrides[].specnprocspec.nprocPerNodespec.trainer.numProcPerNodeNotable fields
tolerations,affinity— go into pod spec /podTemplateOverridesautomaticallyenv_list— full env var dicts supportingvalueFrom/secretKeyRefpod_spec_overrides— arbitrary extra pod spec fields (e.g.resourceClaimsfor IMEX channels)launch(wait=True)— polls untilRUNNING/SUCCEEDED/FAILEDcancel(wait=True)— polls until CR gone and all pods terminatedUNKNOWN/Nonestatus →AppState.PENDING(avoids false failures on transient API errors)Test plan
pytest test/core/execution/test_kubeflow.py test/run/torchx_backend/schedulers/test_kubeflow.py)local/example.py): launch → RUNNING → log sentinel → cancel(wait=True)local/example_trainjob.py)🤖 Generated with Claude Code