From 2b93e4dc55538dfcda443b5f6336480e709d91c3 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Thu, 13 Jun 2024 15:34:43 -0500 Subject: [PATCH 01/17] fix: renaming --- cmd/models.go | 4 ++-- presets/models/{phi-2 => phi2}/README.md | 0 presets/models/{phi-2 => phi2}/model.go | 2 +- presets/models/{phi-3 => phi3}/README.md | 0 presets/models/{phi-3 => phi3}/model.go | 22 +++++++++++----------- 5 files changed, 14 insertions(+), 14 deletions(-) rename presets/models/{phi-2 => phi2}/README.md (100%) rename presets/models/{phi-2 => phi2}/model.go (99%) rename presets/models/{phi-3 => phi3}/README.md (100%) rename presets/models/{phi-3 => phi3}/model.go (92%) diff --git a/cmd/models.go b/cmd/models.go index 986f8dd40..a5ec84624 100644 --- a/cmd/models.go +++ b/cmd/models.go @@ -7,6 +7,6 @@ import ( _ "github.com/azure/kaito/presets/models/llama2" _ "github.com/azure/kaito/presets/models/llama2chat" _ "github.com/azure/kaito/presets/models/mistral" - _ "github.com/azure/kaito/presets/models/phi-2" - _ "github.com/azure/kaito/presets/models/phi-3" + _ "github.com/azure/kaito/presets/models/phi2" + _ "github.com/azure/kaito/presets/models/phi3" ) diff --git a/presets/models/phi-2/README.md b/presets/models/phi2/README.md similarity index 100% rename from presets/models/phi-2/README.md rename to presets/models/phi2/README.md diff --git a/presets/models/phi-2/model.go b/presets/models/phi2/model.go similarity index 99% rename from presets/models/phi-2/model.go rename to presets/models/phi2/model.go index 1b42ec8ae..2e23380b6 100644 --- a/presets/models/phi-2/model.go +++ b/presets/models/phi2/model.go @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -package phi_2 +package phi2 import ( "time" diff --git a/presets/models/phi-3/README.md b/presets/models/phi3/README.md similarity index 100% rename from presets/models/phi-3/README.md rename to presets/models/phi3/README.md diff --git a/presets/models/phi-3/model.go b/presets/models/phi3/model.go similarity index 92% rename from presets/models/phi-3/model.go rename to presets/models/phi3/model.go index cf80187aa..db630850a 100644 --- a/presets/models/phi-3/model.go +++ b/presets/models/phi3/model.go @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -package phi_3 +package phi3 import ( "time" @@ -23,8 +23,8 @@ func init() { } var ( - PresetPhi3Mini4kModel = "phi3Mini4KInst" - PresetPhi3Mini128kModel = "phi3Mini128KInst" + PresetPhi3Mini4kModel = "phi3mini4kinst" + PresetPhi3Mini128kModel = "phi3mini128kinst" PresetPhiTagMap = map[string]string{ "Phi3Mini4kInstruct": "0.0.1", @@ -45,8 +45,8 @@ type phi3Mini4KInst struct{} func (*phi3Mini4KInst) GetInferenceParameters() *model.PresetParam { return &model.PresetParam{ - ModelFamilyName: "Phi", - ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePublic), + ModelFamilyName: "Phi3", + ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePrivate), DiskStorageRequirement: "50Gi", GPUCountRequirement: "1", TotalGPUMemoryRequirement: "9Gi", @@ -60,8 +60,8 @@ func (*phi3Mini4KInst) GetInferenceParameters() *model.PresetParam { } func (*phi3Mini4KInst) GetTuningParameters() *model.PresetParam { return &model.PresetParam{ - ModelFamilyName: "Phi", - ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePublic), + ModelFamilyName: "Phi3", + ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePrivate), DiskStorageRequirement: "50Gi", GPUCountRequirement: "1", TotalGPUMemoryRequirement: "16Gi", @@ -84,8 +84,8 @@ type phi3Mini128KInst struct{} func (*phi3Mini128KInst) GetInferenceParameters() *model.PresetParam { return &model.PresetParam{ - ModelFamilyName: "Phi", - ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePublic), + ModelFamilyName: "Phi3", + ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePrivate), DiskStorageRequirement: "50Gi", GPUCountRequirement: "1", TotalGPUMemoryRequirement: "9Gi", @@ -99,8 +99,8 @@ func (*phi3Mini128KInst) GetInferenceParameters() *model.PresetParam { } func (*phi3Mini128KInst) GetTuningParameters() *model.PresetParam { return &model.PresetParam{ - ModelFamilyName: "Phi", - ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePublic), + ModelFamilyName: "Phi3", + ImageAccessMode: string(kaitov1alpha1.ModelImageAccessModePrivate), DiskStorageRequirement: "50Gi", GPUCountRequirement: "1", TotalGPUMemoryRequirement: "16Gi", From 1753e44106feee98b460280e7ef755bb124b485f Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Thu, 13 Jun 2024 16:05:45 -0500 Subject: [PATCH 02/17] update requirments --- presets/inference/text-generation/requirements.txt | 2 +- presets/tuning/text-generation/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/presets/inference/text-generation/requirements.txt b/presets/inference/text-generation/requirements.txt index 5578ab912..e60cd6743 100644 --- a/presets/inference/text-generation/requirements.txt +++ b/presets/inference/text-generation/requirements.txt @@ -7,7 +7,7 @@ accelerate==0.30.1 fastapi>=0.111.0,<0.112.0 # Allow patch updates pydantic>=2.7.1,<2.8 # Allow patch updates uvicorn[standard]>=0.29.0,<0.30.0 # Allow patch updates -peft +peft==0.11.1 # Utility libraries bitsandbytes==0.42.0 diff --git a/presets/tuning/text-generation/requirements.txt b/presets/tuning/text-generation/requirements.txt index 91cd33e91..614b3690b 100644 --- a/presets/tuning/text-generation/requirements.txt +++ b/presets/tuning/text-generation/requirements.txt @@ -1,5 +1,5 @@ # Core Dependencies -transformers==4.40.2 +transformers==4.41.2 torch==2.2.0 accelerate==0.30.1 fastapi>=0.111.0,<0.112.0 # Allow patch updates @@ -8,7 +8,7 @@ uvicorn[standard]>=0.29.0,<0.30.0 # Allow patch updates # Utility libraries datasets==2.19.1 -peft==0.8.2 +peft==0.11.1 bitsandbytes==0.42.0 # Less critical, can be latest From b5791d9285c9f3fbae1a36f4f1ed390aac0e40c1 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 11:46:18 -0400 Subject: [PATCH 03/17] explicit add numpy --- Makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ac9ed5677..df863f768 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ # Image URL to use all building/pushing image targets -REGISTRY ?= YOUR_REGISTRY -IMG_NAME ?= workspace -VERSION ?= v0.2.2 -GPU_PROVISIONER_VERSION ?= 0.2.0 +REGISTRY ?= aimodelsregistrytest.azurecr.io +IMG_NAME ?= kaito +VERSION ?= v2.0.0 IMG_TAG ?= $(subst v,,$(VERSION)) ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -26,16 +25,16 @@ GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER) AZURE_SUBSCRIPTION_ID ?= $(AZURE_SUBSCRIPTION_ID) AZURE_LOCATION ?= eastus AKS_K8S_VERSION ?= 1.29.2 -AZURE_RESOURCE_GROUP ?= demo -AZURE_CLUSTER_NAME ?= kaito-demo +AZURE_RESOURCE_GROUP ?= llm-test +AZURE_CLUSTER_NAME ?= GitRunner AZURE_RESOURCE_GROUP_MC=MC_$(AZURE_RESOURCE_GROUP)_$(AZURE_CLUSTER_NAME)_$(AZURE_LOCATION) GPU_NAMESPACE ?= gpu-provisioner KAITO_NAMESPACE ?= kaito-workspace GPU_PROVISIONER_MSI_NAME ?= gpuIdentity RUN_LLAMA_13B ?= false -AI_MODELS_REGISTRY ?= modelregistry.azurecr.io -AI_MODELS_REGISTRY_SECRET ?= modelregistry +AI_MODELS_REGISTRY ?= aimodelsregistrytest.azurecr.io +AI_MODELS_REGISTRY_SECRET ?= aimodelsregistry SUPPORTED_MODELS_YAML_PATH ?= /home/runner/work/kaito/kaito/presets/models/supported_models.yaml # Scripts @@ -94,7 +93,7 @@ unit-test: ## Run unit tests. -race -coverprofile=coverage.txt -covermode=atomic go tool cover -func=coverage.txt -inference-api-e2e: +inference-api-e2e: pip install -r presets/inference/text-generation/requirements.txt pytest -o log_cli=true -o log_cli_level=INFO . @@ -152,7 +151,7 @@ prepare-kaito-addon-identity: az-patch-install-helm: ## Update Azure client env vars and settings in helm values.yml az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) - yq -i '(.image.repository) = "$(REGISTRY)/workspace"' ./charts/kaito/workspace/values.yaml + yq -i '(.image.repository) = "$(REGISTRY)/kaito"' ./charts/kaito/workspace/values.yaml yq -i '(.image.tag) = "$(IMG_TAG)"' ./charts/kaito/workspace/values.yaml helm install kaito-workspace ./charts/kaito/workspace --namespace $(KAITO_NAMESPACE) --create-namespace From f438df06c73266a8b1834d1eb205d130e893a239 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 11:57:59 -0400 Subject: [PATCH 04/17] add req --- presets/inference/text-generation/tests/test_inference_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/presets/inference/text-generation/tests/test_inference_api.py b/presets/inference/text-generation/tests/test_inference_api.py index 535d0f4e2..310a0d693 100644 --- a/presets/inference/text-generation/tests/test_inference_api.py +++ b/presets/inference/text-generation/tests/test_inference_api.py @@ -3,6 +3,7 @@ from pathlib import Path from unittest.mock import patch +import numpy as np import pytest from fastapi.testclient import TestClient from transformers import AutoTokenizer From 7e5ae2932899d3080765781e96261ca90ab6c932 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 13:31:46 -0400 Subject: [PATCH 05/17] update device --- presets/inference/text-generation/requirements.txt | 1 + .../inference/text-generation/tests/test_inference_api.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/presets/inference/text-generation/requirements.txt b/presets/inference/text-generation/requirements.txt index e60cd6743..8fe6b041c 100644 --- a/presets/inference/text-generation/requirements.txt +++ b/presets/inference/text-generation/requirements.txt @@ -8,6 +8,7 @@ fastapi>=0.111.0,<0.112.0 # Allow patch updates pydantic>=2.7.1,<2.8 # Allow patch updates uvicorn[standard]>=0.29.0,<0.30.0 # Allow patch updates peft==0.11.1 +numpy==1.22.4 # Utility libraries bitsandbytes==0.42.0 diff --git a/presets/inference/text-generation/tests/test_inference_api.py b/presets/inference/text-generation/tests/test_inference_api.py index 310a0d693..667f5eab7 100644 --- a/presets/inference/text-generation/tests/test_inference_api.py +++ b/presets/inference/text-generation/tests/test_inference_api.py @@ -3,7 +3,7 @@ from pathlib import Path from unittest.mock import patch -import numpy as np +import numpy import pytest from fastapi.testclient import TestClient from transformers import AutoTokenizer @@ -14,8 +14,8 @@ sys.path.append(parent_dir) @pytest.fixture(params=[ - {"pipeline": "text-generation", "model_path": "stanford-crfm/alias-gpt2-small-x21"}, - {"pipeline": "conversational", "model_path": "stanford-crfm/alias-gpt2-small-x21"}, + {"pipeline": "text-generation", "model_path": "stanford-crfm/alias-gpt2-small-x21", "device": "cpu"}, + {"pipeline": "conversational", "model_path": "stanford-crfm/alias-gpt2-small-x21", "device": "cpu"}, ]) def configured_app(request): original_argv = sys.argv.copy() @@ -24,6 +24,7 @@ def configured_app(request): 'program_name', '--pipeline', request.param['pipeline'], '--pretrained_model_name_or_path', request.param['model_path'], + '--device_map', request.param['device'], '--allow_remote_files', 'True' ] sys.argv = test_args From e161fcd0df747b9b8a43aa8431b29621df932b0e Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 13:32:57 -0400 Subject: [PATCH 06/17] removed makefile from PR --- Makefile | 277 ------------------------------------------------------- 1 file changed, 277 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index df863f768..000000000 --- a/Makefile +++ /dev/null @@ -1,277 +0,0 @@ - -# Image URL to use all building/pushing image targets -REGISTRY ?= aimodelsregistrytest.azurecr.io -IMG_NAME ?= kaito -VERSION ?= v2.0.0 -IMG_TAG ?= $(subst v,,$(VERSION)) - -ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) -BIN_DIR := $(abspath $(ROOT_DIR)/bin) - -TOOLS_DIR := hack/tools -TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) - -GOLANGCI_LINT_VER := v1.57.2 -GOLANGCI_LINT_BIN := golangci-lint -GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)) - -E2E_TEST_BIN := e2e.test -E2E_TEST := $(BIN_DIR)/$(E2E_TEST_BIN) - -GINKGO_VER := v2.19.0 -GINKGO_BIN := ginkgo -GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER) - -AZURE_SUBSCRIPTION_ID ?= $(AZURE_SUBSCRIPTION_ID) -AZURE_LOCATION ?= eastus -AKS_K8S_VERSION ?= 1.29.2 -AZURE_RESOURCE_GROUP ?= llm-test -AZURE_CLUSTER_NAME ?= GitRunner -AZURE_RESOURCE_GROUP_MC=MC_$(AZURE_RESOURCE_GROUP)_$(AZURE_CLUSTER_NAME)_$(AZURE_LOCATION) -GPU_NAMESPACE ?= gpu-provisioner -KAITO_NAMESPACE ?= kaito-workspace -GPU_PROVISIONER_MSI_NAME ?= gpuIdentity - -RUN_LLAMA_13B ?= false -AI_MODELS_REGISTRY ?= aimodelsregistrytest.azurecr.io -AI_MODELS_REGISTRY_SECRET ?= aimodelsregistry -SUPPORTED_MODELS_YAML_PATH ?= /home/runner/work/kaito/kaito/presets/models/supported_models.yaml - -# Scripts -GO_INSTALL := ./hack/go-install.sh - -# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) -ifeq (,$(shell go env GOBIN)) -GOBIN=$(shell go env GOPATH)/bin -else -GOBIN=$(shell go env GOBIN) -endif - -## -------------------------------------- -## Tooling Binaries -## -------------------------------------- - -$(GOLANGCI_LINT): - GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) - -$(GINKGO): - GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) $(GINKGO_VER) - -# CONTAINER_TOOL defines the container tool to be used for building images. -# Be aware that the target commands are only tested with Docker which is -# scaffolded by default. However, you might want to replace it to use other -# tools. (i.e. podman) -CONTAINER_TOOL ?= docker - -# Setting SHELL to bash allows bash commands to be executed by recipes. -# Options are set to exit when a recipe line exits non-zero or a piped command fails. -SHELL = /usr/bin/env bash -o pipefail -.SHELLFLAGS = -ec - -##@ Development - -.PHONY: manifests -manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases - cp config/crd/bases/kaito.sh_workspaces.yaml charts/kaito/workspace/crds/ - -.PHONY: generate -generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." - -.PHONY: fmt -fmt: ## Run go fmt against code. - go fmt ./... - -## -------------------------------------- -## Tests -## -------------------------------------- -.PHONY: unit-test -unit-test: ## Run unit tests. - go test -v $(shell go list ./pkg/... ./api/... | \ - grep -v -e /vendor -e /api/v1alpha1/zz_generated.deepcopy.go -e /pkg/utils/test/...) \ - -race -coverprofile=coverage.txt -covermode=atomic - go tool cover -func=coverage.txt - -inference-api-e2e: - pip install -r presets/inference/text-generation/requirements.txt - pytest -o log_cli=true -o log_cli_level=INFO . - -$(E2E_TEST): - (cd test/e2e && go test -c . -o $(E2E_TEST)) - -# Ginkgo configurations -GINKGO_FOCUS ?= -GINKGO_SKIP ?= -GINKGO_NODES ?= 1 -GINKGO_NO_COLOR ?= false -GINKGO_TIMEOUT ?= 60m -GINKGO_ARGS ?= -focus="$(GINKGO_FOCUS)" -skip="$(GINKGO_SKIP)" -nodes=$(GINKGO_NODES) -no-color=$(GINKGO_NO_COLOR) -timeout=$(GINKGO_TIMEOUT) - -.PHONY: kaito-workspace-e2e-test -kaito-workspace-e2e-test: $(E2E_TEST) $(GINKGO) - AI_MODELS_REGISTRY_SECRET=$(AI_MODELS_REGISTRY_SECRET) RUN_LLAMA_13B=$(RUN_LLAMA_13B) \ - AI_MODELS_REGISTRY=$(AI_MODELS_REGISTRY) GPU_NAMESPACE=$(GPU_NAMESPACE) KAITO_NAMESPACE=$(KAITO_NAMESPACE) \ - SUPPORTED_MODELS_YAML_PATH=$(SUPPORTED_MODELS_YAML_PATH) \ - $(GINKGO) -v -trace $(GINKGO_ARGS) $(E2E_TEST) - -.PHONY: create-rg -create-rg: ## Create resource group - az group create --name $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) -o none - -.PHONY: create-acr -create-acr: ## Create test ACR - az acr create --name $(AZURE_ACR_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --sku Standard --admin-enabled -o none - az acr login --name $(AZURE_ACR_NAME) - -.PHONY: create-aks-cluster -create-aks-cluster: ## Create test AKS cluster (with msi, oidc, and workload identity enabled) - az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) \ - --attach-acr $(AZURE_ACR_NAME) --kubernetes-version $(AKS_K8S_VERSION) --node-count 1 --generate-ssh-keys \ - --enable-managed-identity --enable-workload-identity --enable-oidc-issuer -o none - -.PHONY: create-aks-cluster-with-kaito -create-aks-cluster-with-kaito: ## Create test AKS cluster (with msi, oidc and kaito enabled) - az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) --node-count 1 \ - --generate-ssh-keys --enable-managed-identity --enable-oidc-issuer --enable-ai-toolchain-operator -o none - - az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) - -.PHONY: prepare-kaito-addon-identity -prepare-kaito-addon-identity: - IDENTITY_PRINCIPAL_ID=$(shell az identity show --name "ai-toolchain-operator-$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP_MC)" --query 'principalId');\ - az role assignment create --assignee $$IDENTITY_PRINCIPAL_ID --scope "/subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/$(AZURE_RESOURCE_GROUP_MC)" --role "Contributor" - - AKS_OIDC_ISSUER=$(shell az aks show -n "$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP_MC)" --query 'oidcIssuerProfile.issuerUrl');\ - az identity federated-credential create --name gpu-federated-cred --identity-name "ai-toolchain-operator-$(AZURE_CLUSTER_NAME)" \ - -g "$(AZURE_RESOURCE_GROUP)" --issuer $$AKS_OIDC_ISSUER \ - --subject system:serviceaccount:"$(KAITO_NAMESPACE):kaito-gpu-provisioner" --audience api://AzureADTokenExchange - -.PHONY: az-patch-install-helm -az-patch-install-helm: ## Update Azure client env vars and settings in helm values.yml - az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) - - yq -i '(.image.repository) = "$(REGISTRY)/kaito"' ./charts/kaito/workspace/values.yaml - yq -i '(.image.tag) = "$(IMG_TAG)"' ./charts/kaito/workspace/values.yaml - - helm install kaito-workspace ./charts/kaito/workspace --namespace $(KAITO_NAMESPACE) --create-namespace - -##@ Build - -.PHONY: build -build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager cmd/*.go - -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. - go run ./cmd/main.go - -##@ Docker -BUILDX_BUILDER_NAME ?= img-builder -OUTPUT_TYPE ?= type=registry -QEMU_VERSION ?= 5.2.0-2 -ARCH ?= amd64,arm64 - -.PHONY: docker-buildx -docker-buildx: ## Build and push docker image for the manager for cross-platform support - @if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \ - docker run --rm --privileged multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \ - docker buildx create --name $(BUILDX_BUILDER_NAME) --use; \ - docker buildx inspect $(BUILDX_BUILDER_NAME) --bootstrap; \ - fi - -.PHONY: docker-build-kaito -docker-build-kaito: docker-buildx - docker buildx build \ - --file ./docker/kaito/Dockerfile \ - --output=$(OUTPUT_TYPE) \ - --platform="linux/$(ARCH)" \ - --pull \ - --tag $(REGISTRY)/$(IMG_NAME):$(IMG_TAG) . - -##@ Deployment - -ifndef ignore-not-found - ignore-not-found = false -endif - -##@ gpu-provider -gpu-provisioner-identity-perm: ## Create identity for gpu-provisioner - az identity create --name $(GPU_PROVISIONER_MSI_NAME) --resource-group $(AZURE_RESOURCE_GROUP) - - IDENTITY_PRINCIPAL_ID=$(shell az identity show --name $(GPU_PROVISIONER_MSI_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --subscription $(AZURE_SUBSCRIPTION_ID) --query 'principalId');\ - az role assignment create --assignee $$IDENTITY_PRINCIPAL_ID --scope /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/$(AZURE_RESOURCE_GROUP) --role "Contributor" - - AKS_OIDC_ISSUER=$(shell az aks show -n "$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP)" --subscription $(AZURE_SUBSCRIPTION_ID) --query "oidcIssuerProfile.issuerUrl");\ - az identity federated-credential create --name gpu-federatecredential --identity-name $(GPU_PROVISIONER_MSI_NAME) --resource-group "$(AZURE_RESOURCE_GROUP)" --issuer $$AKS_OIDC_ISSUER \ - --subject system:serviceaccount:"$(GPU_NAMESPACE):$(GPU_NAMESPACE)" --audience api://AzureADTokenExchange --subscription $(AZURE_SUBSCRIPTION_ID) - -.PHONY: gpu-provisioner-helm -gpu-provisioner-helm: ## Update Azure client env vars and settings in helm values.yml - az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) - - curl -sO https://raw.githubusercontent.com/Azure/gpu-provisioner/main/hack/deploy/configure-helm-values.sh - chmod +x ./configure-helm-values.sh && ./configure-helm-values.sh $(AZURE_CLUSTER_NAME) $(AZURE_RESOURCE_GROUP) $(GPU_PROVISIONER_MSI_NAME) - - helm install $(GPU_NAMESPACE) --values gpu-provisioner-values.yaml --set settings.azure.clusterName=$(AZURE_CLUSTER_NAME) --wait \ - https://github.com/Azure/gpu-provisioner/raw/gh-pages/charts/gpu-provisioner-$(GPU_PROVISIONER_VERSION).tgz - -##@ Build Dependencies - -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -KUBECTL ?= kubectl -CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen -ENVTEST ?= $(LOCALBIN)/setup-envtest - -## Tool Versions -CONTROLLER_TOOLS_VERSION ?= v0.15.0 - -.PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. -$(CONTROLLER_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ - GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) - -.PHONY: envtest -envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. -$(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest - -## -------------------------------------- -## Linting -## -------------------------------------- -.PHONY: vet -vet: ## Run go vet against code. - go vet ./... - -.PHONY: lint -lint: $(GOLANGCI_LINT) - $(GOLANGCI_LINT) run -v - -## -------------------------------------- -## Release -## To create a release, run `make release VERSION=x.y.z` -## -------------------------------------- -.PHONY: release-manifest -release-manifest: - @sed -i -e 's/^VERSION ?= .*/VERSION ?= ${VERSION}/' ./Makefile - @sed -i -e "s/version: .*/version: ${IMG_TAG}/" ./charts/kaito/workspace/Chart.yaml - @sed -i -e "s/appVersion: .*/appVersion: ${IMG_TAG}/" ./charts/kaito/workspace/Chart.yaml - @sed -i -e "s/tag: .*/tag: ${IMG_TAG}/" ./charts/kaito/workspace/values.yaml - @sed -i -e 's/IMG_TAG=.*/IMG_TAG=${IMG_TAG}/' ./charts/kaito/workspace/README.md - git checkout -b release-${VERSION} - git add ./Makefile ./charts/kaito/workspace/Chart.yaml ./charts/kaito/workspace/values.yaml ./charts/kaito/workspace/README.md - git commit -s -m "release: update manifest and helm charts for ${VERSION}" - -## -------------------------------------- -## Cleanup -## -------------------------------------- - -.PHONY: clean -clean: - @rm -rf $(BIN_DIR) From 36d10606e2dc45e9628593c58e3147e03f4b7237 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 13:34:28 -0400 Subject: [PATCH 07/17] revert --- Makefile | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..ac9ed5677 --- /dev/null +++ b/Makefile @@ -0,0 +1,278 @@ + +# Image URL to use all building/pushing image targets +REGISTRY ?= YOUR_REGISTRY +IMG_NAME ?= workspace +VERSION ?= v0.2.2 +GPU_PROVISIONER_VERSION ?= 0.2.0 +IMG_TAG ?= $(subst v,,$(VERSION)) + +ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +BIN_DIR := $(abspath $(ROOT_DIR)/bin) + +TOOLS_DIR := hack/tools +TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) + +GOLANGCI_LINT_VER := v1.57.2 +GOLANGCI_LINT_BIN := golangci-lint +GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)) + +E2E_TEST_BIN := e2e.test +E2E_TEST := $(BIN_DIR)/$(E2E_TEST_BIN) + +GINKGO_VER := v2.19.0 +GINKGO_BIN := ginkgo +GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER) + +AZURE_SUBSCRIPTION_ID ?= $(AZURE_SUBSCRIPTION_ID) +AZURE_LOCATION ?= eastus +AKS_K8S_VERSION ?= 1.29.2 +AZURE_RESOURCE_GROUP ?= demo +AZURE_CLUSTER_NAME ?= kaito-demo +AZURE_RESOURCE_GROUP_MC=MC_$(AZURE_RESOURCE_GROUP)_$(AZURE_CLUSTER_NAME)_$(AZURE_LOCATION) +GPU_NAMESPACE ?= gpu-provisioner +KAITO_NAMESPACE ?= kaito-workspace +GPU_PROVISIONER_MSI_NAME ?= gpuIdentity + +RUN_LLAMA_13B ?= false +AI_MODELS_REGISTRY ?= modelregistry.azurecr.io +AI_MODELS_REGISTRY_SECRET ?= modelregistry +SUPPORTED_MODELS_YAML_PATH ?= /home/runner/work/kaito/kaito/presets/models/supported_models.yaml + +# Scripts +GO_INSTALL := ./hack/go-install.sh + +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +## -------------------------------------- +## Tooling Binaries +## -------------------------------------- + +$(GOLANGCI_LINT): + GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) + +$(GINKGO): + GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) $(GINKGO_VER) + +# CONTAINER_TOOL defines the container tool to be used for building images. +# Be aware that the target commands are only tested with Docker which is +# scaffolded by default. However, you might want to replace it to use other +# tools. (i.e. podman) +CONTAINER_TOOL ?= docker + +# Setting SHELL to bash allows bash commands to be executed by recipes. +# Options are set to exit when a recipe line exits non-zero or a piped command fails. +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec + +##@ Development + +.PHONY: manifests +manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases + cp config/crd/bases/kaito.sh_workspaces.yaml charts/kaito/workspace/crds/ + +.PHONY: generate +generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." + +.PHONY: fmt +fmt: ## Run go fmt against code. + go fmt ./... + +## -------------------------------------- +## Tests +## -------------------------------------- +.PHONY: unit-test +unit-test: ## Run unit tests. + go test -v $(shell go list ./pkg/... ./api/... | \ + grep -v -e /vendor -e /api/v1alpha1/zz_generated.deepcopy.go -e /pkg/utils/test/...) \ + -race -coverprofile=coverage.txt -covermode=atomic + go tool cover -func=coverage.txt + +inference-api-e2e: + pip install -r presets/inference/text-generation/requirements.txt + pytest -o log_cli=true -o log_cli_level=INFO . + +$(E2E_TEST): + (cd test/e2e && go test -c . -o $(E2E_TEST)) + +# Ginkgo configurations +GINKGO_FOCUS ?= +GINKGO_SKIP ?= +GINKGO_NODES ?= 1 +GINKGO_NO_COLOR ?= false +GINKGO_TIMEOUT ?= 60m +GINKGO_ARGS ?= -focus="$(GINKGO_FOCUS)" -skip="$(GINKGO_SKIP)" -nodes=$(GINKGO_NODES) -no-color=$(GINKGO_NO_COLOR) -timeout=$(GINKGO_TIMEOUT) + +.PHONY: kaito-workspace-e2e-test +kaito-workspace-e2e-test: $(E2E_TEST) $(GINKGO) + AI_MODELS_REGISTRY_SECRET=$(AI_MODELS_REGISTRY_SECRET) RUN_LLAMA_13B=$(RUN_LLAMA_13B) \ + AI_MODELS_REGISTRY=$(AI_MODELS_REGISTRY) GPU_NAMESPACE=$(GPU_NAMESPACE) KAITO_NAMESPACE=$(KAITO_NAMESPACE) \ + SUPPORTED_MODELS_YAML_PATH=$(SUPPORTED_MODELS_YAML_PATH) \ + $(GINKGO) -v -trace $(GINKGO_ARGS) $(E2E_TEST) + +.PHONY: create-rg +create-rg: ## Create resource group + az group create --name $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) -o none + +.PHONY: create-acr +create-acr: ## Create test ACR + az acr create --name $(AZURE_ACR_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --sku Standard --admin-enabled -o none + az acr login --name $(AZURE_ACR_NAME) + +.PHONY: create-aks-cluster +create-aks-cluster: ## Create test AKS cluster (with msi, oidc, and workload identity enabled) + az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) \ + --attach-acr $(AZURE_ACR_NAME) --kubernetes-version $(AKS_K8S_VERSION) --node-count 1 --generate-ssh-keys \ + --enable-managed-identity --enable-workload-identity --enable-oidc-issuer -o none + +.PHONY: create-aks-cluster-with-kaito +create-aks-cluster-with-kaito: ## Create test AKS cluster (with msi, oidc and kaito enabled) + az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) --node-count 1 \ + --generate-ssh-keys --enable-managed-identity --enable-oidc-issuer --enable-ai-toolchain-operator -o none + + az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) + +.PHONY: prepare-kaito-addon-identity +prepare-kaito-addon-identity: + IDENTITY_PRINCIPAL_ID=$(shell az identity show --name "ai-toolchain-operator-$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP_MC)" --query 'principalId');\ + az role assignment create --assignee $$IDENTITY_PRINCIPAL_ID --scope "/subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/$(AZURE_RESOURCE_GROUP_MC)" --role "Contributor" + + AKS_OIDC_ISSUER=$(shell az aks show -n "$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP_MC)" --query 'oidcIssuerProfile.issuerUrl');\ + az identity federated-credential create --name gpu-federated-cred --identity-name "ai-toolchain-operator-$(AZURE_CLUSTER_NAME)" \ + -g "$(AZURE_RESOURCE_GROUP)" --issuer $$AKS_OIDC_ISSUER \ + --subject system:serviceaccount:"$(KAITO_NAMESPACE):kaito-gpu-provisioner" --audience api://AzureADTokenExchange + +.PHONY: az-patch-install-helm +az-patch-install-helm: ## Update Azure client env vars and settings in helm values.yml + az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) + + yq -i '(.image.repository) = "$(REGISTRY)/workspace"' ./charts/kaito/workspace/values.yaml + yq -i '(.image.tag) = "$(IMG_TAG)"' ./charts/kaito/workspace/values.yaml + + helm install kaito-workspace ./charts/kaito/workspace --namespace $(KAITO_NAMESPACE) --create-namespace + +##@ Build + +.PHONY: build +build: manifests generate fmt vet ## Build manager binary. + go build -o bin/manager cmd/*.go + +.PHONY: run +run: manifests generate fmt vet ## Run a controller from your host. + go run ./cmd/main.go + +##@ Docker +BUILDX_BUILDER_NAME ?= img-builder +OUTPUT_TYPE ?= type=registry +QEMU_VERSION ?= 5.2.0-2 +ARCH ?= amd64,arm64 + +.PHONY: docker-buildx +docker-buildx: ## Build and push docker image for the manager for cross-platform support + @if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \ + docker run --rm --privileged multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \ + docker buildx create --name $(BUILDX_BUILDER_NAME) --use; \ + docker buildx inspect $(BUILDX_BUILDER_NAME) --bootstrap; \ + fi + +.PHONY: docker-build-kaito +docker-build-kaito: docker-buildx + docker buildx build \ + --file ./docker/kaito/Dockerfile \ + --output=$(OUTPUT_TYPE) \ + --platform="linux/$(ARCH)" \ + --pull \ + --tag $(REGISTRY)/$(IMG_NAME):$(IMG_TAG) . + +##@ Deployment + +ifndef ignore-not-found + ignore-not-found = false +endif + +##@ gpu-provider +gpu-provisioner-identity-perm: ## Create identity for gpu-provisioner + az identity create --name $(GPU_PROVISIONER_MSI_NAME) --resource-group $(AZURE_RESOURCE_GROUP) + + IDENTITY_PRINCIPAL_ID=$(shell az identity show --name $(GPU_PROVISIONER_MSI_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --subscription $(AZURE_SUBSCRIPTION_ID) --query 'principalId');\ + az role assignment create --assignee $$IDENTITY_PRINCIPAL_ID --scope /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/$(AZURE_RESOURCE_GROUP) --role "Contributor" + + AKS_OIDC_ISSUER=$(shell az aks show -n "$(AZURE_CLUSTER_NAME)" -g "$(AZURE_RESOURCE_GROUP)" --subscription $(AZURE_SUBSCRIPTION_ID) --query "oidcIssuerProfile.issuerUrl");\ + az identity federated-credential create --name gpu-federatecredential --identity-name $(GPU_PROVISIONER_MSI_NAME) --resource-group "$(AZURE_RESOURCE_GROUP)" --issuer $$AKS_OIDC_ISSUER \ + --subject system:serviceaccount:"$(GPU_NAMESPACE):$(GPU_NAMESPACE)" --audience api://AzureADTokenExchange --subscription $(AZURE_SUBSCRIPTION_ID) + +.PHONY: gpu-provisioner-helm +gpu-provisioner-helm: ## Update Azure client env vars and settings in helm values.yml + az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) + + curl -sO https://raw.githubusercontent.com/Azure/gpu-provisioner/main/hack/deploy/configure-helm-values.sh + chmod +x ./configure-helm-values.sh && ./configure-helm-values.sh $(AZURE_CLUSTER_NAME) $(AZURE_RESOURCE_GROUP) $(GPU_PROVISIONER_MSI_NAME) + + helm install $(GPU_NAMESPACE) --values gpu-provisioner-values.yaml --set settings.azure.clusterName=$(AZURE_CLUSTER_NAME) --wait \ + https://github.com/Azure/gpu-provisioner/raw/gh-pages/charts/gpu-provisioner-$(GPU_PROVISIONER_VERSION).tgz + +##@ Build Dependencies + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +KUBECTL ?= kubectl +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +ENVTEST ?= $(LOCALBIN)/setup-envtest + +## Tool Versions +CONTROLLER_TOOLS_VERSION ?= v0.15.0 + +.PHONY: controller-gen +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. +$(CONTROLLER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + +.PHONY: envtest +envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. +$(ENVTEST): $(LOCALBIN) + test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + +## -------------------------------------- +## Linting +## -------------------------------------- +.PHONY: vet +vet: ## Run go vet against code. + go vet ./... + +.PHONY: lint +lint: $(GOLANGCI_LINT) + $(GOLANGCI_LINT) run -v + +## -------------------------------------- +## Release +## To create a release, run `make release VERSION=x.y.z` +## -------------------------------------- +.PHONY: release-manifest +release-manifest: + @sed -i -e 's/^VERSION ?= .*/VERSION ?= ${VERSION}/' ./Makefile + @sed -i -e "s/version: .*/version: ${IMG_TAG}/" ./charts/kaito/workspace/Chart.yaml + @sed -i -e "s/appVersion: .*/appVersion: ${IMG_TAG}/" ./charts/kaito/workspace/Chart.yaml + @sed -i -e "s/tag: .*/tag: ${IMG_TAG}/" ./charts/kaito/workspace/values.yaml + @sed -i -e 's/IMG_TAG=.*/IMG_TAG=${IMG_TAG}/' ./charts/kaito/workspace/README.md + git checkout -b release-${VERSION} + git add ./Makefile ./charts/kaito/workspace/Chart.yaml ./charts/kaito/workspace/values.yaml ./charts/kaito/workspace/README.md + git commit -s -m "release: update manifest and helm charts for ${VERSION}" + +## -------------------------------------- +## Cleanup +## -------------------------------------- + +.PHONY: clean +clean: + @rm -rf $(BIN_DIR) From ed5752688038dfbc56bd26970e7562dfe22a54bf Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 13:38:34 -0400 Subject: [PATCH 08/17] update naming --- presets/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presets/README.md b/presets/README.md index fa9a94cbb..422e83b10 100644 --- a/presets/README.md +++ b/presets/README.md @@ -7,7 +7,7 @@ The current supported model families with preset configurations are listed below | [llama2](./models/llama2) | v0.0.1+| | [llama2chat](./models/llama2chat) | v0.0.1+| | [mistral](./models/mistral) | v0.2.0+| -| [phi2](./models/phi-2) | v0.2.0+| +| [phi2](./models/phi2) | v0.2.0+| ## Validation Each preset model has its own hardware requirements in terms of GPU count and GPU memory defined in the respective `model.go` file. Kaito controller performs a validation check of whether the specified SKU and node count are sufficient to run the model or not. In case the provided SKU is not in the known list, the controller bypasses the validation check which means users need to ensure the model can run with the provided SKU. From 4cd2409b10efca6e57904d4b8dfec39ffa2fa474 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 18:09:28 -0400 Subject: [PATCH 09/17] feat: Upload examples and rename plugin --- .../kaito_workspace_tuning_falcon_7b.yaml | 20 ------------------- .../kaito_workspace_tuning_phi_3.yaml | 19 ++++++++++++++++++ .../kaito_workspace_phi-3-adapter.yaml | 17 ++++++++++++++++ examples/inference/kaito_workspace_phi-3.yaml | 13 ++++++++++++ presets/models/phi3/model.go | 4 ++-- 5 files changed, 51 insertions(+), 22 deletions(-) delete mode 100644 examples/fine-tuning/kaito_workspace_tuning_falcon_7b.yaml create mode 100644 examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml create mode 100644 examples/inference/kaito_workspace_phi-3-adapter.yaml create mode 100644 examples/inference/kaito_workspace_phi-3.yaml diff --git a/examples/fine-tuning/kaito_workspace_tuning_falcon_7b.yaml b/examples/fine-tuning/kaito_workspace_tuning_falcon_7b.yaml deleted file mode 100644 index 6d6ed7831..000000000 --- a/examples/fine-tuning/kaito_workspace_tuning_falcon_7b.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: kaito.sh/v1alpha1 -kind: Workspace -metadata: - name: workspace-tuning-falcon-7b -spec: - resource: - instanceType: "Standard_NC12s_v3" - labelSelector: - matchLabels: - app: tuning-falcon-7b - tuning: - preset: - name: falcon-7b - method: lora - config: tuning-config-map # ConfigMap containing tuning arguments - input: - name: tuning-data - hostPath: /path/to/your/input/data # dataset on node - output: - hostPath: /path/to/store/output # Tuning Output diff --git a/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml b/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml new file mode 100644 index 000000000..b133bd35c --- /dev/null +++ b/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml @@ -0,0 +1,19 @@ +apiVersion: kaito.sh/v1alpha1 +kind: Workspace +metadata: + name: workspace-tuning-phi-3 +resource: + instanceType: "Standard_NC6s_v3" + labelSelector: + matchLabels: + app: tuning-phi-3 +tuning: + preset: + name: phi-3-mini-128k-instruct + method: qlora + input: + urls: + - "https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca/resolve/main/data/train-00000-of-00001-8b6e212f3e1ece96.parquet?download=true" + output: + image: "ACR_REPO_HERE.azurecr.io/ADAPTER_HERE:0.0.1" # Tuning Output ACR Path + imagePushSecret: ACR_REGISTRY_SECRET_HERE diff --git a/examples/inference/kaito_workspace_phi-3-adapter.yaml b/examples/inference/kaito_workspace_phi-3-adapter.yaml new file mode 100644 index 000000000..8dd754c48 --- /dev/null +++ b/examples/inference/kaito_workspace_phi-3-adapter.yaml @@ -0,0 +1,17 @@ +apiVersion: kaito.sh/v1alpha1 +kind: Workspace +metadata: + name: workspace-phi-3-mini-adapter +resource: + instanceType: "Standard_NC6s_v3" + labelSelector: + matchLabels: + apps: phi-3-adapter +inference: + preset: + name: phi-3-mini-128k-instruct + adapters: + - source: + name: "phi-3-adapter" + image: "ACR_REPO_HERE.azurecr.io/ADAPTER_HERE:0.0.1" + strength: "1.0" diff --git a/examples/inference/kaito_workspace_phi-3.yaml b/examples/inference/kaito_workspace_phi-3.yaml new file mode 100644 index 000000000..aa2a2cfe2 --- /dev/null +++ b/examples/inference/kaito_workspace_phi-3.yaml @@ -0,0 +1,13 @@ +apiVersion: kaito.sh/v1alpha1 +kind: Workspace +metadata: + name: workspace-phi-3-mini +resource: + instanceType: "Standard_NC6s_v3" + labelSelector: + matchLabels: + apps: phi-3 +inference: + preset: + name: phi-3-mini-4k-instruct + # Note: This configuration also works with the phi-3-mini-128k-instruct preset diff --git a/presets/models/phi3/model.go b/presets/models/phi3/model.go index db630850a..420c0d9fa 100644 --- a/presets/models/phi3/model.go +++ b/presets/models/phi3/model.go @@ -23,8 +23,8 @@ func init() { } var ( - PresetPhi3Mini4kModel = "phi3mini4kinst" - PresetPhi3Mini128kModel = "phi3mini128kinst" + PresetPhi3Mini4kModel = "phi-3-mini-4k-instruct" + PresetPhi3Mini128kModel = "phi-3-mini-128k-instruct" PresetPhiTagMap = map[string]string{ "Phi3Mini4kInstruct": "0.0.1", From 6cd359bc39b617bd014112b3af73eed31deb5eb5 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 18:10:30 -0400 Subject: [PATCH 10/17] fix: download url --- examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml b/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml index b133bd35c..71b57bce2 100644 --- a/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml +++ b/examples/fine-tuning/kaito_workspace_tuning_phi_3.yaml @@ -13,7 +13,7 @@ tuning: method: qlora input: urls: - - "https://huggingface.co/datasets/iamtarun/python_code_instructions_18k_alpaca/resolve/main/data/train-00000-of-00001-8b6e212f3e1ece96.parquet?download=true" + - "https://huggingface.co/datasets/philschmid/dolly-15k-oai-style/resolve/main/data/train-00000-of-00001-54e3756291ca09c6.parquet?download=true" output: image: "ACR_REPO_HERE.azurecr.io/ADAPTER_HERE:0.0.1" # Tuning Output ACR Path imagePushSecret: ACR_REGISTRY_SECRET_HERE From e2b058780c2463523e813ed2507d17d1325936e5 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 18:32:56 -0400 Subject: [PATCH 11/17] chore: update configmap naming --- api/v1alpha1/params_validation.go | 11 ++++++----- api/v1alpha1/workspace_types.go | 9 ++++----- api/v1alpha1/workspace_validation.go | 4 ++-- charts/kaito/workspace/crds/kaito.sh_workspaces.yaml | 9 ++++----- config/crd/bases/kaito.sh_workspaces.yaml | 9 ++++----- pkg/tuning/preset-tuning.go | 9 +++++---- pkg/tuning/preset-tuning_test.go | 6 +++--- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/api/v1alpha1/params_validation.go b/api/v1alpha1/params_validation.go index 897e5f340..e4b034e9a 100644 --- a/api/v1alpha1/params_validation.go +++ b/api/v1alpha1/params_validation.go @@ -6,6 +6,10 @@ package v1alpha1 import ( "context" "fmt" + "path/filepath" + "reflect" + "strings" + "github.com/azure/kaito/pkg/k8sclient" "github.com/azure/kaito/pkg/utils" "gopkg.in/yaml.v2" @@ -13,10 +17,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "knative.dev/pkg/apis" - "path/filepath" - "reflect" "sigs.k8s.io/controller-runtime/pkg/client" - "strings" ) type Config struct { @@ -257,9 +258,9 @@ func (r *TuningSpec) validateConfigMap(ctx context.Context, namespace string, me err := k8sclient.Client.Get(ctx, client.ObjectKey{Name: configMapName, Namespace: namespace}, &cm) if err != nil { if errors.IsNotFound(err) { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("ConfigMap '%s' specified in 'config' not found in namespace '%s'", r.ConfigTemplate, namespace), "config")) + errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("ConfigMap '%s' specified in 'config' not found in namespace '%s'", r.Config, namespace), "config")) } else { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("Failed to get ConfigMap '%s' in namespace '%s': %v", r.ConfigTemplate, namespace, err), "config")) + errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("Failed to get ConfigMap '%s' in namespace '%s': %v", r.Config, namespace, err), "config")) } } else { if err := validateConfigMapSchema(&cm); err != nil { diff --git a/api/v1alpha1/workspace_types.go b/api/v1alpha1/workspace_types.go index a55566320..52eb4a899 100644 --- a/api/v1alpha1/workspace_types.go +++ b/api/v1alpha1/workspace_types.go @@ -149,12 +149,11 @@ type TuningSpec struct { // Method specifies the Parameter-Efficient Fine-Tuning(PEFT) method, such as lora, qlora, used for the tuning. // +optional Method TuningMethod `json:"method,omitempty"` - // ConfigTemplate specifies the name of the configmap that contains the basic tuning arguments. - // A separate configmap will be generated based on the ConfigTemplate and the preset model name, and used by - // the tuning Job. If specified, the congfigmap needs to be in the same namespace of the workspace custom resource. - // If not specified, a default ConfigTemplate is used based on the specified tuning method. + // Config specifies the name of a custom ConfigMap that contains tuning arguments. + // If specified, the ConfigMap must be in the same namespace as the Workspace custom resource. + // If not specified, a default Config is used based on the specified tuning method. // +optional - ConfigTemplate string `json:"configTemplate,omitempty"` + Config string `json:"config,omitempty"` // Input describes the input used by the tuning method. Input *DataSource `json:"input"` // Output specified where to store the tuning output. diff --git a/api/v1alpha1/workspace_validation.go b/api/v1alpha1/workspace_validation.go index d6808beaa..fbe8a24de 100644 --- a/api/v1alpha1/workspace_validation.go +++ b/api/v1alpha1/workspace_validation.go @@ -133,7 +133,7 @@ func (r *TuningSpec) validateCreate(ctx context.Context, workspaceNamespace stri if methodLowerCase != string(TuningMethodLora) && methodLowerCase != string(TuningMethodQLora) { errs = errs.Also(apis.ErrInvalidValue(r.Method, "Method")) } - if r.ConfigTemplate == "" { + if r.Config == "" { klog.InfoS("Tuning config not specified. Using default based on method.") releaseNamespace, err := utils.GetReleaseNamespace() if err != nil { @@ -149,7 +149,7 @@ func (r *TuningSpec) validateCreate(ctx context.Context, workspaceNamespace stri errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("Failed to evaluate validateConfigMap: %v", err), "Config")) } } else { - if err := r.validateConfigMap(ctx, workspaceNamespace, methodLowerCase, r.ConfigTemplate); err != nil { + if err := r.validateConfigMap(ctx, workspaceNamespace, methodLowerCase, r.Config); err != nil { errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("Failed to evaluate validateConfigMap: %v", err), "Config")) } } diff --git a/charts/kaito/workspace/crds/kaito.sh_workspaces.yaml b/charts/kaito/workspace/crds/kaito.sh_workspaces.yaml index 36de64f68..ed0441120 100644 --- a/charts/kaito/workspace/crds/kaito.sh_workspaces.yaml +++ b/charts/kaito/workspace/crds/kaito.sh_workspaces.yaml @@ -299,12 +299,11 @@ spec: type: object tuning: properties: - configTemplate: + config: description: |- - ConfigTemplate specifies the name of the configmap that contains the basic tuning arguments. - A separate configmap will be generated based on the ConfigTemplate and the preset model name, and used by - the tuning Job. If specified, the congfigmap needs to be in the same namespace of the workspace custom resource. - If not specified, a default ConfigTemplate is used based on the specified tuning method. + Config specifies the name of a custom ConfigMap that contains tuning arguments. + If specified, the ConfigMap must be in the same namespace as the Workspace custom resource. + If not specified, a default Config is used based on the specified tuning method. type: string input: description: Input describes the input used by the tuning method. diff --git a/config/crd/bases/kaito.sh_workspaces.yaml b/config/crd/bases/kaito.sh_workspaces.yaml index 36de64f68..ed0441120 100644 --- a/config/crd/bases/kaito.sh_workspaces.yaml +++ b/config/crd/bases/kaito.sh_workspaces.yaml @@ -299,12 +299,11 @@ spec: type: object tuning: properties: - configTemplate: + config: description: |- - ConfigTemplate specifies the name of the configmap that contains the basic tuning arguments. - A separate configmap will be generated based on the ConfigTemplate and the preset model name, and used by - the tuning Job. If specified, the congfigmap needs to be in the same namespace of the workspace custom resource. - If not specified, a default ConfigTemplate is used based on the specified tuning method. + Config specifies the name of a custom ConfigMap that contains tuning arguments. + If specified, the ConfigMap must be in the same namespace as the Workspace custom resource. + If not specified, a default Config is used based on the specified tuning method. type: string input: description: Input describes the input used by the tuning method. diff --git a/pkg/tuning/preset-tuning.go b/pkg/tuning/preset-tuning.go index bd52c3664..afb6d3d1d 100644 --- a/pkg/tuning/preset-tuning.go +++ b/pkg/tuning/preset-tuning.go @@ -3,13 +3,14 @@ package tuning import ( "context" "fmt" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" - "knative.dev/pkg/apis" "os" "path/filepath" "strings" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/pointer" + "knative.dev/pkg/apis" + "k8s.io/apimachinery/pkg/api/resource" kaitov1alpha1 "github.com/azure/kaito/api/v1alpha1" @@ -96,7 +97,7 @@ func GetDataSrcImageInfo(ctx context.Context, wObj *kaitov1alpha1.Workspace) (st // - If not, check the release namespace and copy it to the target namespace if found. func EnsureTuningConfigMap(ctx context.Context, workspaceObj *kaitov1alpha1.Workspace, kubeClient client.Client) (*corev1.ConfigMap, error) { - tuningConfigMapName := workspaceObj.Tuning.ConfigTemplate + tuningConfigMapName := workspaceObj.Tuning.Config if tuningConfigMapName == "" { if workspaceObj.Tuning.Method == kaitov1alpha1.TuningMethodLora { tuningConfigMapName = kaitov1alpha1.DefaultLoraConfigMapTemplate diff --git a/pkg/tuning/preset-tuning_test.go b/pkg/tuning/preset-tuning_test.go index 8ca64c334..4e26cfcca 100644 --- a/pkg/tuning/preset-tuning_test.go +++ b/pkg/tuning/preset-tuning_test.go @@ -196,7 +196,7 @@ func TestEnsureTuningConfigMap(t *testing.T) { }, workspaceObj: &kaitov1alpha1.Workspace{ Tuning: &kaitov1alpha1.TuningSpec{ - ConfigTemplate: "config-template", + Config: "config-template", }, }, expectedError: "", @@ -207,7 +207,7 @@ func TestEnsureTuningConfigMap(t *testing.T) { }, workspaceObj: &kaitov1alpha1.Workspace{ Tuning: &kaitov1alpha1.TuningSpec{ - ConfigTemplate: "config-template", + Config: "config-template", }, }, expectedError: "failed to get release namespace: failed to determine release namespace from file /var/run/secrets/kubernetes.io/serviceaccount/namespace and env var RELEASE_NAMESPACE", @@ -221,7 +221,7 @@ func TestEnsureTuningConfigMap(t *testing.T) { }, workspaceObj: &kaitov1alpha1.Workspace{ Tuning: &kaitov1alpha1.TuningSpec{ - ConfigTemplate: "config-template", + Config: "config-template", }, }, expectedError: "failed to get ConfigMap from template namespace: \"config-template\" not found", From 627922fbbb7c9ea774ae82741e0e89a61776f7cb Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Mon, 17 Jun 2024 18:38:52 -0400 Subject: [PATCH 12/17] fix: update readme --- presets/models/phi3/README.md | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/presets/models/phi3/README.md b/presets/models/phi3/README.md index 7ecd6c1a4..b61c83731 100644 --- a/presets/models/phi3/README.md +++ b/presets/models/phi3/README.md @@ -10,39 +10,19 @@ ## Usage -Phi-3 Mini models are best suited for prompts using the chat format as follows. You can provide the prompt as a question with a generic template as follow: +Phi-3 Mini models are best suited for prompts using the chat format as follows. You can provide the prompt as a question with a generic template as follows: ``` <|user|>\nQuestion<|end|>\n<|assistant|> ``` -For example: -``` -<|user|> -How to explain Internet for a medieval knight?<|end|> -<|assistant|> - -``` - -Or in the case of few shots prompt: -``` -<|user|> -I am going to Paris, what should I see?<|end|> -<|assistant|> -Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|> -<|user|> -What is so great about #1?<|end|> -<|assistant|> -``` +For more information on usage, check the phi-3 repo: [Phi-3 Repo](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) The inference service endpoint is `/chat`. ### Basic example ``` -curl -X POST "http://:80/chat" -H "accept: application/json" -H "Content-Type: application/json" -d '{"prompt":"YOUR_PROMPT_HERE"}' -``` -``` curl -X POST "http://:80/chat" -H "accept: application/json" -H "Content-Type: application/json" -d '{"prompt":"<|user|> How to explain Internet for a medieval knight?<|end|><|assistant|>"}' ``` @@ -53,7 +33,7 @@ curl -X POST \ -H "accept: application/json" \ -H "Content-Type: application/json" \ -d '{ - "prompt":"YOUR_PROMPT_HERE", + "prompt":"<|user|> What is the meaning of life?<|end|><|assistant|>", "return_full_text": false, "clean_up_tokenization_spaces": false, "prefix": null, From 785388907a4b37ebb8a3b334e5ebda3291e68d8d Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Tue, 18 Jun 2024 12:15:22 -0400 Subject: [PATCH 13/17] nit: file renaming --- .../{kaito_workspace_phi-2.yaml => kaito_workspace_phi_2.yaml} | 0 .../{kaito_workspace_phi-3.yaml => kaito_workspace_phi_3.yaml} | 0 ...hi-3-adapter.yaml => kaito_workspace_phi_3_with_adapters.yaml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename examples/inference/{kaito_workspace_phi-2.yaml => kaito_workspace_phi_2.yaml} (100%) rename examples/inference/{kaito_workspace_phi-3.yaml => kaito_workspace_phi_3.yaml} (100%) rename examples/inference/{kaito_workspace_phi-3-adapter.yaml => kaito_workspace_phi_3_with_adapters.yaml} (100%) diff --git a/examples/inference/kaito_workspace_phi-2.yaml b/examples/inference/kaito_workspace_phi_2.yaml similarity index 100% rename from examples/inference/kaito_workspace_phi-2.yaml rename to examples/inference/kaito_workspace_phi_2.yaml diff --git a/examples/inference/kaito_workspace_phi-3.yaml b/examples/inference/kaito_workspace_phi_3.yaml similarity index 100% rename from examples/inference/kaito_workspace_phi-3.yaml rename to examples/inference/kaito_workspace_phi_3.yaml diff --git a/examples/inference/kaito_workspace_phi-3-adapter.yaml b/examples/inference/kaito_workspace_phi_3_with_adapters.yaml similarity index 100% rename from examples/inference/kaito_workspace_phi-3-adapter.yaml rename to examples/inference/kaito_workspace_phi_3_with_adapters.yaml From c8a26137342fa8b5223b9b1594ff1065d62bf7e2 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Tue, 18 Jun 2024 12:21:25 -0400 Subject: [PATCH 14/17] nit: update readmes --- presets/models/phi2/README.md | 2 +- presets/models/phi3/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/presets/models/phi2/README.md b/presets/models/phi2/README.md index 1e77252a5..8ecaaa4b1 100644 --- a/presets/models/phi2/README.md +++ b/presets/models/phi2/README.md @@ -1,7 +1,7 @@ ## Supported Models |Model name| Model source | Sample workspace|Kubernetes Workload|Distributed inference| |----|:----:|:----:| :----: |:----: | -|phi-2 |[microsoft](https://huggingface.co/microsoft/phi-2)|[link](../../../examples/inference/kaito_workspace_phi-2.yaml)|Deployment| false| +|phi-2 |[microsoft](https://huggingface.co/microsoft/phi-2)|[link](../../../examples/inference/kaito_workspace_phi_3.yaml)|Deployment| false| ## Image Source diff --git a/presets/models/phi3/README.md b/presets/models/phi3/README.md index b61c83731..c39d8d5b2 100644 --- a/presets/models/phi3/README.md +++ b/presets/models/phi3/README.md @@ -1,8 +1,8 @@ ## Supported Models | Model name | Model source | Sample workspace|Kubernetes Workload|Distributed inference| |--------------------------|:----:|:----:| :----: |:----: | -| phi-3-mini-4k-instruct |[microsoft](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct)|[link](../../../examples/inference/kaito_workspace_phi-2.yaml)|Deployment| false| -| phi-3-mini-128k-instruct |[microsoft](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct)|[link](../../../examples/inference/kaito_workspace_phi-2.yaml)|Deployment| false| +| phi-3-mini-4k-instruct |[microsoft](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct)|[link](../../../examples/inference/kaito_workspace_phi_3.yaml)|Deployment| false| +| phi-3-mini-128k-instruct |[microsoft](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct)|[link](../../../examples/inference/kaito_workspace_phi_3.yaml)|Deployment| false| ## Image Source From fed01cc0551138adbf8e5d7735d9d19efd306c94 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Tue, 18 Jun 2024 12:45:01 -0400 Subject: [PATCH 15/17] fix: raise not implemented for volumes --- api/v1alpha1/workspace_validation.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/workspace_validation.go b/api/v1alpha1/workspace_validation.go index fbe8a24de..d44f2e57c 100644 --- a/api/v1alpha1/workspace_validation.go +++ b/api/v1alpha1/workspace_validation.go @@ -200,6 +200,7 @@ func (r *DataSource) validateCreate() (errs *apis.FieldError) { sourcesSpecified++ } if r.Volume != nil { + errs = errs.Also(apis.ErrInvalidValue("Volume support is not implemented yet", "Volume")) sourcesSpecified++ } // Regex checks for a / and a colon followed by a tag @@ -223,6 +224,9 @@ func (r *DataSource) validateUpdate(old *DataSource, isTuning bool) (errs *apis. if isTuning && !reflect.DeepEqual(old.Name, r.Name) { errs = errs.Also(apis.ErrInvalidValue("During tuning Name field cannot be changed once set", "Name")) } + if r.Volume != nil { + errs = errs.Also(apis.ErrInvalidValue("Volume support is not implemented yet", "Volume")) + } oldURLs := make([]string, len(old.URLs)) copy(oldURLs, old.URLs) sort.Strings(oldURLs) @@ -255,7 +259,9 @@ func (r *DataSource) validateUpdate(old *DataSource, isTuning bool) (errs *apis. func (r *DataDestination) validateCreate() (errs *apis.FieldError) { destinationsSpecified := 0 + // TODO: Implement Volumes if r.Volume != nil { + errs = errs.Also(apis.ErrInvalidValue("Volume support is not implemented yet", "Volume")) destinationsSpecified++ } if r.Image != "" { @@ -279,7 +285,10 @@ func (r *DataDestination) validateCreate() (errs *apis.FieldError) { } func (r *DataDestination) validateUpdate(old *DataDestination) (errs *apis.FieldError) { - // TODO: Check if the Volume is changed. + // TODO: Implement Volumes + if r.Volume != nil { + errs = errs.Also(apis.ErrInvalidValue("Volume support is not implemented yet", "Volume")) + } if old.Image != r.Image { errs = errs.Also(apis.ErrInvalidValue("Image field cannot be changed once set", "Image")) } From c81ef8f7092ca20700f9c5732809377d388202ed Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Tue, 18 Jun 2024 14:09:50 -0400 Subject: [PATCH 16/17] fix: update tests --- api/v1alpha1/workspace_validation_test.go | 81 +++++++++++------------ 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/api/v1alpha1/workspace_validation_test.go b/api/v1alpha1/workspace_validation_test.go index 1a1bfdd4a..23084368c 100644 --- a/api/v1alpha1/workspace_validation_test.go +++ b/api/v1alpha1/workspace_validation_test.go @@ -893,8 +893,8 @@ func TestTuningSpecValidateCreate(t *testing.T) { { name: "All fields valid", tuningSpec: &TuningSpec{ - Input: &DataSource{Name: "valid-input", Volume: &v1.VolumeSource{}}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Input: &DataSource{Name: "valid-input", Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, @@ -904,8 +904,8 @@ func TestTuningSpecValidateCreate(t *testing.T) { { name: "Verify QLoRA Config", tuningSpec: &TuningSpec{ - Input: &DataSource{Name: "valid-input", Volume: &v1.VolumeSource{}}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Input: &DataSource{Name: "valid-input", Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodQLora, }, @@ -915,7 +915,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { { name: "Missing Input", tuningSpec: &TuningSpec{ - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, @@ -936,7 +936,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Missing Preset", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Method: TuningMethodLora, }, wantErr: true, @@ -946,7 +946,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Invalid Preset", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("invalid-preset")}}, Method: TuningMethodLora, }, @@ -957,7 +957,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Invalid Method", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: "invalid-method", }, @@ -999,13 +999,13 @@ func TestTuningSpecValidateUpdate(t *testing.T) { name: "No changes", oldTuning: &TuningSpec{ Input: &DataSource{Name: "input1"}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, newTuning: &TuningSpec{ Input: &DataSource{Name: "input1"}, - Output: &DataDestination{Volume: &v1.VolumeSource{}}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, @@ -1072,7 +1072,7 @@ func TestDataSourceValidateCreate(t *testing.T) { { name: "Volume specified only", dataSource: &DataSource{ - Volume: &v1.VolumeSource{}, + Image: "AZURE_ACR.azurecr.io/test:0.0.0", }, wantErr: false, }, @@ -1105,20 +1105,19 @@ func TestDataSourceValidateCreate(t *testing.T) { wantErr: true, errField: "Exactly one of URLs, Volume, or Image must be specified", }, - { - name: "URLs and Volume specified", - dataSource: &DataSource{ - URLs: []string{"http://example.com/data"}, - Volume: &v1.VolumeSource{}, - }, - wantErr: true, - errField: "Exactly one of URLs, Volume, or Image must be specified", - }, + // { + // name: "URLs and Volume specified", + // dataSource: &DataSource{ + // URLs: []string{"http://example.com/data"}, + // Volume: &v1.VolumeSource{}, + // }, + // wantErr: true, + // errField: "Exactly one of URLs, Volume, or Image must be specified", + // }, { name: "All fields specified", dataSource: &DataSource{ URLs: []string{"http://example.com/data"}, - Volume: &v1.VolumeSource{}, Image: "aimodels.azurecr.io/data-image:latest", }, wantErr: true, @@ -1154,13 +1153,13 @@ func TestDataSourceValidateUpdate(t *testing.T) { name: "No changes", oldSource: &DataSource{ URLs: []string{"http://example.com/data1", "http://example.com/data2"}, - Volume: &v1.VolumeSource{}, + // Volume: &v1.VolumeSource{}, Image: "data-image:latest", ImagePullSecrets: []string{"secret1", "secret2"}, }, newSource: &DataSource{ URLs: []string{"http://example.com/data2", "http://example.com/data1"}, // Note the different order, should not matter - Volume: &v1.VolumeSource{}, + // Volume: &v1.VolumeSource{}, Image: "data-image:latest", ImagePullSecrets: []string{"secret2", "secret1"}, // Note the different order, should not matter }, @@ -1245,13 +1244,13 @@ func TestDataDestinationValidateCreate(t *testing.T) { wantErr: true, errField: "At least one of Volume or Image must be specified", }, - { - name: "Volume specified only", - dataDestination: &DataDestination{ - Volume: &v1.VolumeSource{}, - }, - wantErr: false, - }, + // { + // name: "Volume specified only", + // dataDestination: &DataDestination{ + // Volume: &v1.VolumeSource{}, + // }, + // wantErr: false, + // }, { name: "Image specified only", dataDestination: &DataDestination{ @@ -1276,15 +1275,15 @@ func TestDataDestinationValidateCreate(t *testing.T) { }, wantErr: true, }, - { - name: "Both fields specified", - dataDestination: &DataDestination{ - Volume: &v1.VolumeSource{}, - Image: "aimodels.azurecr.io/data-image:latest", - ImagePushSecret: "imagePushSecret", - }, - wantErr: false, - }, + // { + // name: "Both fields specified", + // dataDestination: &DataDestination{ + // Volume: &v1.VolumeSource{}, + // Image: "aimodels.azurecr.io/data-image:latest", + // ImagePushSecret: "imagePushSecret", + // }, + // wantErr: false, + // }, } for _, tt := range tests { @@ -1314,12 +1313,12 @@ func TestDataDestinationValidateUpdate(t *testing.T) { { name: "No changes", oldDest: &DataDestination{ - Volume: &v1.VolumeSource{}, + // Volume: &v1.VolumeSource{}, Image: "old-image:latest", ImagePushSecret: "old-secret", }, newDest: &DataDestination{ - Volume: &v1.VolumeSource{}, + // Volume: &v1.VolumeSource{}, Image: "old-image:latest", ImagePushSecret: "old-secret", }, From 14d86ff226f3f4b3549368d657ae7dfb0f2ce592 Mon Sep 17 00:00:00 2001 From: ishaansehgal99 Date: Tue, 18 Jun 2024 14:22:41 -0400 Subject: [PATCH 17/17] fix: Add Image Push Secret --- api/v1alpha1/workspace_validation_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/v1alpha1/workspace_validation_test.go b/api/v1alpha1/workspace_validation_test.go index 23084368c..7f585eede 100644 --- a/api/v1alpha1/workspace_validation_test.go +++ b/api/v1alpha1/workspace_validation_test.go @@ -894,7 +894,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "All fields valid", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input", Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: "secret"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, @@ -905,7 +905,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Verify QLoRA Config", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input", Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: "secret"}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodQLora, }, @@ -915,7 +915,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { { name: "Missing Input", tuningSpec: &TuningSpec{ - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: ""}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: TuningMethodLora, }, @@ -936,7 +936,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Missing Preset", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: ""}, Method: TuningMethodLora, }, wantErr: true, @@ -946,7 +946,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Invalid Preset", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: ""}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("invalid-preset")}}, Method: TuningMethodLora, }, @@ -957,7 +957,7 @@ func TestTuningSpecValidateCreate(t *testing.T) { name: "Invalid Method", tuningSpec: &TuningSpec{ Input: &DataSource{Name: "valid-input"}, - Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0"}, + Output: &DataDestination{Image: "AZURE_ACR.azurecr.io/test:0.0.0", ImagePushSecret: ""}, Preset: &PresetSpec{PresetMeta: PresetMeta{Name: ModelName("test-validation")}}, Method: "invalid-method", },