forked from kubeflow/training-operator
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ted chang <[email protected]>
- Loading branch information
1 parent
a08246d
commit 700e8e3
Showing
12 changed files
with
968 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"model_name_or_path": "bigscience/bloom-560m", | ||
"training_data_path": "/etc/config/twitter_complaints_small.json", | ||
"output_dir": "/tmp/out", | ||
"num_train_epochs": 1.0, | ||
"per_device_train_batch_size": 4, | ||
"per_device_eval_batch_size": 4, | ||
"gradient_accumulation_steps": 4, | ||
"evaluation_strategy": "no", | ||
"save_strategy": "epoch", | ||
"learning_rate": 1e-5, | ||
"weight_decay": 0.0, | ||
"lr_scheduler_type": "cosine", | ||
"logging_steps": 1.0, | ||
"packing": false, | ||
"include_tokens_per_second": true, | ||
"response_template": "\n### Label:", | ||
"dataset_text_field": "output", | ||
"use_flash_attn": false, | ||
"torch_dtype": "float32", | ||
"peft_method": "pt", | ||
"tokenizer_name_or_path": "bigscience/bloom" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
Copyright 2023. | ||
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. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/onsi/gomega" | ||
. "github.com/onsi/gomega" | ||
. "github.com/project-codeflare/codeflare-common/support" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
kftov1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" | ||
) | ||
|
||
func PytorchJob(t Test, namespace, name string) func(g gomega.Gomega) *kftov1.PyTorchJob { | ||
return func(g gomega.Gomega) *kftov1.PyTorchJob { | ||
job, err := t.Client().Kubeflow().KubeflowV1().PyTorchJobs(namespace).Get(t.Ctx(), name, metav1.GetOptions{}) | ||
g.Expect(err).NotTo(gomega.HaveOccurred()) | ||
return job | ||
} | ||
} | ||
|
||
func PytorchJobCondition(job *kftov1.PyTorchJob) string { | ||
if len(job.Status.Conditions) == 0 { | ||
return "" | ||
} | ||
return job.Status.Conditions[len(job.Status.Conditions)-1].Reason | ||
} | ||
|
||
func TestPytorchjobWithSFTtrainer(t *testing.T) { | ||
test := With(t) | ||
test.T().Parallel() | ||
|
||
// Create a namespace | ||
namespace := test.NewTestNamespace() | ||
config := &corev1.ConfigMap{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: corev1.SchemeGroupVersion.String(), | ||
Kind: "ConfigMap", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "my-config", | ||
Namespace: namespace.Name, | ||
Labels: map[string]string{ | ||
"kueue.x-k8s.io/queue-name": "lq-trainer", | ||
}, | ||
}, | ||
BinaryData: map[string][]byte{ | ||
"config.json": ReadFile(test, "config.json"), | ||
"twitter_complaints_small.json": ReadFile(test, "twitter_complaints_small.json"), | ||
}, | ||
Immutable: Ptr(true), | ||
} | ||
|
||
config, err := test.Client().Core().CoreV1().ConfigMaps(namespace.Name).Create(test.Ctx(), config, metav1.CreateOptions{}) | ||
test.Expect(err).NotTo(HaveOccurred()) | ||
test.T().Logf("Created ConfigMap %s/%s successfully", config.Namespace, config.Name) | ||
|
||
tuningJob := &kftov1.PyTorchJob{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: corev1.SchemeGroupVersion.String(), | ||
Kind: "PyTorchJob", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "kfto-sft", | ||
Namespace: namespace.Name, | ||
}, | ||
Spec: kftov1.PyTorchJobSpec{ | ||
PyTorchReplicaSpecs: map[kftov1.ReplicaType]*kftov1.ReplicaSpec{ | ||
"Master": &kftov1.ReplicaSpec{ | ||
Replicas: Ptr(int32(1)), | ||
RestartPolicy: "Never", | ||
Template: corev1.PodTemplateSpec{ | ||
Spec: corev1.PodSpec{ | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: "pytorch", | ||
Image: "quay.io/tedchang/sft-trainer:dev", | ||
ImagePullPolicy: corev1.PullIfNotPresent, | ||
Command: []string{"python", "/app/launch_training.py"}, | ||
Env: []corev1.EnvVar{ | ||
{ | ||
Name: "SFT_TRAINER_CONFIG_JSON_PATH", | ||
Value: "/etc/config/config.json", | ||
}, | ||
}, | ||
VolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "config-volume", | ||
MountPath: "/etc/config", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Volumes: []corev1.Volume{ | ||
{ | ||
Name: "config-volume", | ||
VolumeSource: corev1.VolumeSource{ | ||
ConfigMap: &corev1.ConfigMapVolumeSource{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: "my-config", | ||
}, | ||
Items: []corev1.KeyToPath{ | ||
{ | ||
Key: "config.json", | ||
Path: "config.json", | ||
}, | ||
{ | ||
Key: "twitter_complaints_small.json", | ||
Path: "twitter_complaints_small.json", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
tuningJob, err = test.Client().Kubeflow().KubeflowV1().PyTorchJobs(namespace.Name).Create(test.Ctx(), tuningJob, metav1.CreateOptions{}) | ||
test.Expect(err).NotTo(HaveOccurred()) | ||
test.T().Logf("Created PytorchJob %s/%s successfully", tuningJob.Namespace, tuningJob.Name) | ||
|
||
test.Eventually(PytorchJob(test, namespace.Name, tuningJob.Name), TestTimeoutLong).Should(WithTransform(PytorchJobCondition, Equal("PyTorchJobSucceeded"))) | ||
test.T().Logf("PytorchJob %s/%s ran successfully", tuningJob.Namespace, tuningJob.Name) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1 | ||
extraPortMappings: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
protocol: TCP | ||
kubeadmConfigPatches: | ||
- | | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
node-labels: "ingress-ready=true" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 IBM, Red Hat | ||
# | ||
# 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. | ||
|
||
set -euo pipefail | ||
: "${INGRESS_NGINX_VERSION:=controller-v1.9.6}" | ||
|
||
BASE_DIR=`pwd` | ||
TEST_DIR="${BASE_DIR}/test/e2e" | ||
|
||
echo "Creating KinD cluster" | ||
kind create cluster --name training-operator-cluster --config ${TEST_DIR}/kind-cluster-config.yaml | ||
|
||
echo "Deploying Ingress controller into KinD cluster" | ||
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/"${INGRESS_NGINX_VERSION}"/deploy/static/provider/kind/deploy.yaml | sed "s/--publish-status-address=localhost/--report-node-internal-ip-address\\n - --status-update-interval=10/g" | kubectl apply -f - | ||
kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true" | ||
kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: kueue.x-k8s.io/v1beta1 | ||
kind: ResourceFlavor | ||
metadata: | ||
name: "cpu-flavor" | ||
--- | ||
apiVersion: kueue.x-k8s.io/v1beta1 | ||
kind: ClusterQueue | ||
metadata: | ||
name: "cq-small" | ||
spec: | ||
namespaceSelector: {} # match all. | ||
resourceGroups: | ||
- coveredResources: ["cpu", "memory"] | ||
flavors: | ||
- name: "cpu-flavor" | ||
resources: | ||
- name: "cpu" | ||
nominalQuota: 5 | ||
- name: "memory" | ||
nominalQuota: 20Gi | ||
--- | ||
apiVersion: kueue.x-k8s.io/v1beta1 | ||
kind: LocalQueue | ||
metadata: | ||
name: lq-trainer | ||
namespace: default | ||
spec: | ||
clusterQueue: cq-small |
Oops, something went wrong.