Skip to content
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

feat: Add fine tuning spec in CRD #292

Merged
merged 3 commits into from
Mar 13, 2024
Merged
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
75 changes: 73 additions & 2 deletions api/v1alpha1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type PresetOptions struct {
// Image is the name of the containerized model image.
// +optional
Image string `json:"image,omitempty"`
// ImagePullSecrets is a list of secret names in the same namespace used for pulling the image.
// ImagePullSecrets is a list of secret names in the same namespace used for pulling the model image.
// +optional
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
}
Expand All @@ -73,7 +73,7 @@ type PresetSpec struct {
}

type InferenceSpec struct {
// Preset describles the model that will be deployed with preset configurations.
// Preset describes the base model that will be deployed with preset configurations.
// +optional
Preset *PresetSpec `json:"preset,omitempty"`
// Template specifies the Pod template used to run the inference service. Users can specify custom Pod settings
Expand All @@ -83,6 +83,76 @@ type InferenceSpec struct {
// +kubebuilder:validation:Schemaless
// +optional
Template *v1.PodTemplateSpec `json:"template,omitempty"`
// Adapters are integrated into the base model for inference.
// Users can specify multiple adapters for the model and the respective weight of using each of them.
// +optional
Adapters []AdapterSpec `json:"adapters,omitempty"`
}

type AdapterSpec struct {
// Source describes where to obtain the adapter data.
// +optional
Source *DataSource `json:"source,omitempty"`
// Strength specifies the default multiplier for applying the adapter weights to the raw model weights.
// It is usually a float number between 0 and 1. It is defined as a string type to be language agnostic.
// +optional
Strength *string `json:"strength,omitempty"`
}

type DataSource struct {
// The name of the dataset. The same name will be used as a container name.
// It must be a valid DNS subdomain value,
Name string `json:"name,omitempty"`
// URLs specifies the links to the public data sources. E.g., files in a public github repository.
// +optional
URLs []string `json:"urls,omitempty"`
// The directory in the hsot that contains the data.
// +optional
HostPath string `json:"hostPath,omitempty"`
// The name of the image that contains the source data. The assumption is that the source data locates in the
// `data` directory in the image.
// +optional
Image string `json:"image,omitempty"`
// ImagePullSecrets is a list of secret names in the same namespace used for pulling the data image.
// +optional
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
}

type DataDestination struct {
// The directory in the host that contains the output data.
// +optional
HostPath string `json:"hostPath,omitempty"`
// Name of the image where the output data is pushed to.
// +optional
Image string `json:"image,omitempty"`
// ImagePushSecret is the name of the secret in the same namespace that contains the authentication
// information that is needed for running `docker push`.
// +optional
ImagePushSecret string `json:"imagePushSecret,omitempty"`
Fei-Guo marked this conversation as resolved.
Show resolved Hide resolved
}

type TuningMethod string

const (
TuningMethodLora TuningMethod = "lora"
TuningMethodQLora TuningMethod = "qlora"
)

type TuningSpec struct {
// Preset describes which model to load for tuning.
// +optional
Preset *PresetSpec `json:"preset,omitempty"`
// Method specifies the Parameter-Efficient Fine-Tuning(PEFT) method, such as lora, qlora, used for the tuning.
// +optional
Method TuningMethod `json:"method,omitempty"`
// Config specifies the name of the configmap in the same namespace that contains the arguments used by the tuning method.
// If not specified, a default configmap is used based on the specified method.
// +optional
Config string `json:"config,omitempty"`
// Input describes the input used by the tuning method.
Input *DataSource `json:"input,omitempty"`
// Output specified where to store the tuning output.
Output *DataDestination `json:"output,omitempty"`
}

// WorkspaceStatus defines the observed state of Workspace
Expand Down Expand Up @@ -112,6 +182,7 @@ type Workspace struct {

Resource ResourceSpec `json:"resource,omitempty"`
Inference InferenceSpec `json:"inference,omitempty"`
Tuning TuningSpec `json:"tuning,omitempty"`
Status WorkspaceStatus `json:"status,omitempty"`
}

Expand Down
103 changes: 103 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 137 additions & 3 deletions config/crd/bases/kaito.sh_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,53 @@ spec:
type: string
inference:
properties:
adapters:
description: Adapters are integrated into the base model for inference.
Users can specify multiple adapters for the model and the respective
weight of using each of them.
items:
properties:
source:
description: Source describes where to obtain the adapter data.
properties:
hostPath:
description: The directory in the hsot that contains the
data.
type: string
image:
description: The name of the image that contains the source
data. The assumption is that the source data locates in
the `data` directory in the image.
type: string
imagePullSecrets:
description: ImagePullSecrets is a list of secret names
in the same namespace used for pulling the data image.
items:
type: string
type: array
name:
description: The name of the dataset. The same name will
be used as a container name. It must be a valid DNS subdomain
value,
type: string
urls:
description: URLs specifies the links to the public data
sources. E.g., files in a public github repository.
items:
type: string
type: array
type: object
strength:
description: Strength specifies the default multiplier for applying
the adapter weights to the raw model weights. It is usually
a float number between 0 and 1. It is defined as a string
type to be language agnostic.
type: string
type: object
type: array
preset:
description: Preset describles the model that will be deployed with
preset configurations.
description: Preset describes the base model that will be deployed
with preset configurations.
properties:
accessMode:
description: AccessMode specifies whether the containerized model
Expand All @@ -72,7 +116,7 @@ spec:
type: string
imagePullSecrets:
description: ImagePullSecrets is a list of secret names in
the same namespace used for pulling the image.
the same namespace used for pulling the model image.
items:
type: string
type: array
Expand Down Expand Up @@ -245,6 +289,96 @@ spec:
type: string
type: array
type: object
tuning:
properties:
config:
description: Config specifies the name of the configmap in the same
namespace that contains the arguments used by the tuning method.
If not specified, a default configmap is used based on the specified
method.
type: string
input:
description: Input describes the input used by the tuning method.
properties:
hostPath:
description: The directory in the hsot that contains the data.
type: string
image:
description: The name of the image that contains the source data.
The assumption is that the source data locates in the `data`
directory in the image.
type: string
imagePullSecrets:
description: ImagePullSecrets is a list of secret names in the
same namespace used for pulling the data image.
items:
type: string
type: array
name:
description: The name of the dataset. The same name will be used
as a container name. It must be a valid DNS subdomain value,
type: string
urls:
description: URLs specifies the links to the public data sources.
E.g., files in a public github repository.
items:
type: string
type: array
type: object
method:
description: Method specifies the Parameter-Efficient Fine-Tuning(PEFT)
method, such as lora, qlora, used for the tuning.
type: string
output:
description: Output specified where to store the tuning output.
properties:
hostPath:
description: The directory in the host that contains the output
data.
type: string
image:
description: Name of the image where the output data is pushed
to.
type: string
imagePushSecret:
description: ImagePushSecret is the name of the secret in the
same namespace that contains the authentication information
that is needed for running `docker push`.
type: string
type: object
preset:
description: Preset describes which model to load for tuning.
properties:
accessMode:
description: AccessMode specifies whether the containerized model
image is accessible via public registry or private registry.
This field defaults to "public" if not specified. If this field
is "private", user needs to provide the private image information
in PresetOptions.
enum:
- public
- private
type: string
name:
description: Name of the supported models with preset configurations.
type: string
presetOptions:
properties:
image:
description: Image is the name of the containerized model
image.
type: string
imagePullSecrets:
description: ImagePullSecrets is a list of secret names in
the same namespace used for pulling the model image.
items:
type: string
type: array
type: object
required:
- name
type: object
type: object
type: object
served: true
storage: true
Expand Down
Loading