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 RDMA definition to datasource #455

Merged
merged 1 commit into from
Dec 27, 2023
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
4 changes: 4 additions & 0 deletions api/base/v1alpha1/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type DatasourceType string

const (
DatasourceTypeOSS DatasourceType = "oss"
DatasourceTypeRDMA DatasourceType = "RDMA"
DatasourceTypeUnknown DatasourceType = "unknown"
)

Expand All @@ -32,6 +33,9 @@ func (ds DatasourceSpec) Type() DatasourceType {
if ds.OSS != nil {
return DatasourceTypeOSS
}
if ds.RDMA != nil {
return DatasourceTypeRDMA
}

return DatasourceTypeUnknown
}
10 changes: 10 additions & 0 deletions api/base/v1alpha1/datasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ type DatasourceSpec struct {

// OSS defines info for object storage service
OSS *OSS `json:"oss,omitempty"`

// RDMA configure RDMA pulls the model file directly from the remote service to the host node.
RDMA *RDMA `json:"rdma,omitempty"`
}

type RDMA struct {
// Path on a model storage server, the usual storage path is /path/ns/mode-name, and the path field is /path/, which must end in /.
// example: /opt/kubeagi/, /opt/, /
// +kubebuilder:validation:Pattern=(^\/$)|(^\/[a-zA-Z0-9\_.@-]+(\/[a-zA-Z0-9\_.@-]+)*\/$)
Path string `json:"path"`
}

// OSS defines info for object storage service as datasource
Expand Down
6 changes: 2 additions & 4 deletions api/base/v1alpha1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ type ModelSpec struct {
// Comma separated field which can be wrapped by {llm,embedding}
Types string `json:"types,omitempty"`

// TODO: extend model to utilize third party storage sources
// Source *TypedObjectReference `json:"source,omitempty"`
// // Path(relative to source) to the model files
// Path string `json:"path,omitempty"`
// Source define the source of the model file
Source *TypedObjectReference `json:"source,omitempty"`
}

// ModelStatus defines the observed state of Model
Expand Down
27 changes: 26 additions & 1 deletion api/base/v1alpha1/zz_generated.deepcopy.go

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

13 changes: 13 additions & 0 deletions config/crd/bases/arcadia.kubeagi.k8s.com.cn_datasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ spec:
description: Object must end with a slash "/" if it is a directory
type: string
type: object
rdma:
description: RDMA configure RDMA pulls the model file directly from
the remote service to the host node.
properties:
path:
description: 'Path on a model storage server, the usual storage
path is /path/ns/mode-name, and the path field is /path/, which
must end in /. example: /opt/kubeagi/, /opt/, /'
pattern: (^\/$)|(^\/[a-zA-Z0-9\_.@-]+(\/[a-zA-Z0-9\_.@-]+)*\/$)
type: string
required:
- path
type: object
required:
- endpoint
type: object
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ spec:
displayName:
description: DisplayName defines datasource display name
type: string
source:
description: Source define the source of the model file
properties:
apiGroup:
description: APIGroup is the group for the resource being referenced.
If APIGroup is not specified, the specified Kind must be in
the core API group. For any other third-party types, APIGroup
is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
namespace:
description: Namespace is the namespace of resource being referenced
type: string
required:
- kind
- name
type: object
types:
description: Type defines what kind of model this is Comma separated
field which can be wrapped by {llm,embedding}
Expand Down
58 changes: 32 additions & 26 deletions controllers/model_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,40 @@ func (r *ModelReconciler) Initialize(ctx context.Context, logger logr.Logger, in
// CheckModel to update status
func (r *ModelReconciler) CheckModel(ctx context.Context, logger logr.Logger, instance *arcadiav1alpha1.Model) error {
logger.V(5).Info("check model")
var err error

var ds datasource.Datasource
var info any

system, err := config.GetSystemDatasource(ctx, r.Client, nil)
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
endpoint := system.Spec.Endpoint.DeepCopy()
if endpoint != nil && endpoint.AuthSecret != nil {
endpoint.AuthSecret.WithNameSpace(system.Namespace)
}
ds, err = datasource.NewLocal(ctx, r.Client, endpoint)
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
// oss info:
// - bucket: same as the instance namespace
// - object: path joined with "model/{instance.name}"
info = &arcadiav1alpha1.OSS{
Bucket: instance.Namespace,
Object: instance.ObjectPath(),
}
var (
ds datasource.Datasource
info any
)

// If source is empty, it means that the data is still sourced from the internal minio and a state check is required,
// otherwise we consider the model file for the trans-core service to be ready.
if instance.Spec.Source == nil {
logger.V(5).Info(fmt.Sprintf("model %s source is empty, check minio status.", instance.Name))
system, err := config.GetSystemDatasource(ctx, r.Client, nil)
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
endpoint := system.Spec.Endpoint.DeepCopy()
if endpoint != nil && endpoint.AuthSecret != nil {
endpoint.AuthSecret.WithNameSpace(system.Namespace)
}
ds, err = datasource.NewLocal(ctx, r.Client, endpoint)
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
// oss info:
// - bucket: same as the instance namespace
// - object: path joined with "model/{instance.name}"
info = &arcadiav1alpha1.OSS{
Bucket: instance.Namespace,
Object: instance.ObjectPath(),
}

// check datasource against info
if err := ds.Stat(ctx, info); err != nil {
return r.UpdateStatus(ctx, instance, err)
// check datasource against info
if err := ds.Stat(ctx, info); err != nil {
return r.UpdateStatus(ctx, instance, err)
}
}

// update status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ spec:
description: Object must end with a slash "/" if it is a directory
type: string
type: object
rdma:
description: RDMA configure RDMA pulls the model file directly from
the remote service to the host node.
properties:
path:
description: 'Path on a model storage server, the usual storage
path is /path/ns/mode-name, and the path field is /path/, which
must end in /. example: /opt/kubeagi/, /opt/, /'
pattern: (^\/$)|(^\/[a-zA-Z0-9\_.@-]+(\/[a-zA-Z0-9\_.@-]+)*\/$)
type: string
required:
- path
type: object
required:
- endpoint
type: object
Expand Down
22 changes: 22 additions & 0 deletions deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ spec:
displayName:
description: DisplayName defines datasource display name
type: string
source:
description: Source define the source of the model file
properties:
apiGroup:
description: APIGroup is the group for the resource being referenced.
If APIGroup is not specified, the specified Kind must be in
the core API group. For any other third-party types, APIGroup
is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
namespace:
description: Namespace is the namespace of resource being referenced
type: string
required:
- kind
- name
type: object
types:
description: Type defines what kind of model this is Comma separated
field which can be wrapped by {llm,embedding}
Expand Down