Skip to content

[WIP] Implement TrainerClient Backends & Local Process #33

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
605 changes: 47 additions & 558 deletions python/kubeflow/trainer/api/trainer_client.py

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions python/kubeflow/trainer/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 The Kubeflow Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from kubeflow.trainer.backends.k8s import K8SBackend
from kubeflow.trainer.backends.local_process import LocalProcessBackend
from kubeflow.trainer.types.backends import K8SBackendConfig, LocalProcessBackendConfig

TRAINER_BACKEND_REGISTRY = {
"kubernetes": {
"backend_cls": K8SBackend,
"config_cls": K8SBackendConfig,
},
"local": {
"backend_cls": LocalProcessBackend,
"config_cls": LocalProcessBackendConfig,
}
}
62 changes: 62 additions & 0 deletions python/kubeflow/trainer/backends/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2025 The Kubeflow Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import abc

from typing import Dict, List, Optional
from kubeflow.trainer.constants import constants
from kubeflow.trainer.types import types


class TrainingBackend(abc.ABC):

@abc.abstractmethod
def list_runtimes(self) -> List[types.Runtime]:
raise NotImplementedError()

@abc.abstractmethod
def get_runtime(self, name: str) -> Optional[types.Runtime]:
raise NotImplementedError()

@abc.abstractmethod
def train(self,
train_job_name: str,
runtime: types.Runtime,
initializer: Optional[types.Initializer] = None,
trainer: Optional[types.Trainer] = None,
) -> str:
raise NotImplementedError()

@abc.abstractmethod
def list_jobs(
self, runtime: Optional[types.Runtime] = None
) -> List[types.TrainJob]:
raise NotImplementedError()

@abc.abstractmethod
def get_job(self, name: str) -> Optional[types.TrainJob]:
raise NotImplementedError()

@abc.abstractmethod
def get_job_logs(self,
name: str,
follow: Optional[bool] = False,
step: str = constants.NODE,
node_rank: int = 0,
) -> Dict[str, str]:
raise NotImplementedError()

@abc.abstractmethod
def delete_job(self, name: str) -> None:
raise NotImplementedError()
Loading