diff --git a/api/core/v1alpha1/model_types.go b/api/core/v1alpha1/model_types.go index 976a56e3..fe92f753 100644 --- a/api/core/v1alpha1/model_types.go +++ b/api/core/v1alpha1/model_types.go @@ -46,7 +46,7 @@ type ModelHub struct { // in the near future. Filename *string `json:"filename,omitempty"` // Revision refers to a Git revision id which can be a branch name, a tag, or a commit hash. - // Most of the time, you don't need to specify it. + // +kubebuilder:default=main // +optional Revision *string `json:"revision,omitempty"` } diff --git a/config/crd/bases/llmaz.io_openmodels.yaml b/config/crd/bases/llmaz.io_openmodels.yaml index c4f90103..1d87e4b2 100644 --- a/config/crd/bases/llmaz.io_openmodels.yaml +++ b/config/crd/bases/llmaz.io_openmodels.yaml @@ -130,9 +130,9 @@ spec: - ModelScope type: string revision: - description: |- - Revision refers to a Git revision id which can be a branch name, a tag, or a commit hash. - Most of the time, you don't need to specify it. + default: main + description: Revision refers to a Git revision id which can + be a branch name, a tag, or a commit hash. type: string type: object uri: diff --git a/pkg/controller_helper/model_source/modelsource_test.go b/pkg/controller_helper/model_source/modelsource_test.go index a6153e71..f4bbb8a4 100644 --- a/pkg/controller_helper/model_source/modelsource_test.go +++ b/pkg/controller_helper/model_source/modelsource_test.go @@ -39,7 +39,7 @@ func Test_ModelSourceProvider(t *testing.T) { }, { name: "modelhub with GGUF file", - model: wrapper.MakeModel("test-7b").FamilyName("test").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf").Obj(), + model: wrapper.MakeModel("test-7b").FamilyName("test").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf", "").Obj(), wantModelName: "test-7b", wantModelPath: "/workspace/models/qwen2-0_5b-instruct-q5_k_m.gguf", }, diff --git a/test/e2e/playground_test.go b/test/e2e/playground_test.go index 2b2f2e31..5376bda9 100644 --- a/test/e2e/playground_test.go +++ b/test/e2e/playground_test.go @@ -48,7 +48,7 @@ var _ = ginkgo.Describe("playground e2e tests", func() { }) ginkgo.It("Deploy a huggingface model with llama.cpp", func() { - model := wrapper.MakeModel("qwen2-0-5b-gguf").FamilyName("qwen2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf").Obj() + model := wrapper.MakeModel("qwen2-0-5b-gguf").FamilyName("qwen2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf", "").Obj() gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) defer func() { gomega.Expect(k8sClient.Delete(ctx, model)).To(gomega.Succeed()) @@ -73,7 +73,7 @@ var _ = ginkgo.Describe("playground e2e tests", func() { Request("cpu", "2").Request("memory", "4Gi").Limit("cpu", "4").Limit("memory", "4Gi").Obj() gomega.Expect(k8sClient.Create(ctx, backendRuntime)).To(gomega.Succeed()) - model := wrapper.MakeModel("qwen2-0-5b-gguf").FamilyName("qwen2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf").Obj() + model := wrapper.MakeModel("qwen2-0-5b-gguf").FamilyName("qwen2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf", "").Obj() gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) defer func() { gomega.Expect(k8sClient.Delete(ctx, model)).To(gomega.Succeed()) @@ -92,12 +92,12 @@ var _ = ginkgo.Describe("playground e2e tests", func() { }) // TODO: add e2e tests. // ginkgo.It("SpeculativeDecoding with llama.cpp", func() { - // targetModel := wrapper.MakeModel("llama2-7b-q8-gguf").FamilyName("llama2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("TheBloke/Llama-2-7B-GGUF", "llama-2-7b.Q8_0.gguf").Obj() + // targetModel := wrapper.MakeModel("llama2-7b-q8-gguf").FamilyName("llama2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("TheBloke/Llama-2-7B-GGUF", "llama-2-7b.Q8_0.gguf", "").Obj() // gomega.Expect(k8sClient.Create(ctx, targetModel)).To(gomega.Succeed()) // defer func() { // gomega.Expect(k8sClient.Delete(ctx, targetModel)).To(gomega.Succeed()) // }() - // draftModel := wrapper.MakeModel("llama2-7b-q2-k-gguf").FamilyName("llama2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("TheBloke/Llama-2-7B-GGUF", "llama-2-7b.Q2_K.gguf").Obj() + // draftModel := wrapper.MakeModel("llama2-7b-q2-k-gguf").FamilyName("llama2").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("TheBloke/Llama-2-7B-GGUF", "llama-2-7b.Q2_K.gguf", "").Obj() // gomega.Expect(k8sClient.Create(ctx, draftModel)).To(gomega.Succeed()) // defer func() { // gomega.Expect(k8sClient.Delete(ctx, draftModel)).To(gomega.Succeed()) diff --git a/test/integration/controller/inference/playground_test.go b/test/integration/controller/inference/playground_test.go index a13b382d..6356808a 100644 --- a/test/integration/controller/inference/playground_test.go +++ b/test/integration/controller/inference/playground_test.go @@ -57,7 +57,7 @@ var _ = ginkgo.Describe("playground controller test", func() { gomega.Expect(k8sClient.Create(ctx, ns)).To(gomega.Succeed()) model = util.MockASampleModel() gomega.Expect(k8sClient.Create(ctx, model)).To(gomega.Succeed()) - draftModel = wrapper.MakeModel("llama3-2b").FamilyName("llama3").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("meta-llama/Meta-Llama-3-2B", "").Obj() + draftModel = wrapper.MakeModel("llama3-2b").FamilyName("llama3").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("meta-llama/Meta-Llama-3-2B", "", "").Obj() gomega.Expect(k8sClient.Create(ctx, draftModel)).To(gomega.Succeed()) }) ginkgo.AfterEach(func() { diff --git a/test/integration/webhook/model_test.go b/test/integration/webhook/model_test.go index afad3c0d..3e3c8b5a 100644 --- a/test/integration/webhook/model_test.go +++ b/test/integration/webhook/model_test.go @@ -52,18 +52,18 @@ var _ = ginkgo.Describe("model default and validation", func() { }, ginkgo.Entry("apply model family name", &testDefaultingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "").FamilyName("llama3").Obj() + return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "", "").FamilyName("llama3").Obj() }, wantModel: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "").ModelSourceWithModelHub("Huggingface").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() + return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "", "main").ModelSourceWithModelHub("Huggingface").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() }, }), ginkgo.Entry("apply modelscope model hub name", &testDefaultingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "").Obj() + return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "").Obj() }, wantModel: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "").ModelSourceWithModelHub("ModelScope").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() + return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "main").ModelSourceWithModelHub("ModelScope").FamilyName("llama3").Label(coreapi.ModelFamilyNameLabelKey, "llama3").Obj() }, }), ) @@ -83,19 +83,19 @@ var _ = ginkgo.Describe("model default and validation", func() { }, ginkgo.Entry("default normal huggingface model creation", &testValidatingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "").Obj() + return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "", "").Obj() }, failed: false, }), ginkgo.Entry("normal modelScope model creation", &testValidatingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "").Obj() + return wrapper.MakeModel("llama3-8b").FamilyName("llama3").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("LLM-Research/Meta-Llama-3-8B", "", "").Obj() }, failed: false, }), ginkgo.Entry("invalid model name", &testValidatingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("qwen-2-0.5b").FamilyName("qwen2").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct", "").Obj() + return wrapper.MakeModel("qwen-2-0.5b").FamilyName("qwen2").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct", "", "").Obj() }, failed: true, }), @@ -131,13 +131,13 @@ var _ = ginkgo.Describe("model default and validation", func() { }), ginkgo.Entry("set filename when modelHub is Huggingface", &testValidatingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf").FamilyName("llama3").Obj() + return wrapper.MakeModel("llama3-8b").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf", "").FamilyName("llama3").Obj() }, failed: false, }), ginkgo.Entry("set filename when modelHub is ModelScope", &testValidatingCase{ model: func() *coreapi.OpenModel { - return wrapper.MakeModel("llama3-8b").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf").FamilyName("llama3").Obj() + return wrapper.MakeModel("llama3-8b").ModelSourceWithModelHub("ModelScope").ModelSourceWithModelID("Qwen/Qwen2-0.5B-Instruct-GGUF", "qwen2-0_5b-instruct-q5_k_m.gguf", "").FamilyName("llama3").Obj() }, failed: true, }), diff --git a/test/util/mock.go b/test/util/mock.go index 54b14327..e3dd2f97 100644 --- a/test/util/mock.go +++ b/test/util/mock.go @@ -26,7 +26,7 @@ const ( ) func MockASampleModel() *coreapi.OpenModel { - return wrapper.MakeModel(sampleModelName).FamilyName("llama3").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "").Obj() + return wrapper.MakeModel(sampleModelName).FamilyName("llama3").ModelSourceWithModelHub("Huggingface").ModelSourceWithModelID("meta-llama/Meta-Llama-3-8B", "", "").Obj() } func MockASamplePlayground(ns string) *inferenceapi.Playground { diff --git a/test/util/wrapper/model.go b/test/util/wrapper/model.go index ee14009e..0e7b1f89 100644 --- a/test/util/wrapper/model.go +++ b/test/util/wrapper/model.go @@ -47,7 +47,7 @@ func (w *ModelWrapper) FamilyName(name string) *ModelWrapper { return w } -func (w *ModelWrapper) ModelSourceWithModelID(modelID string, filename string) *ModelWrapper { +func (w *ModelWrapper) ModelSourceWithModelID(modelID string, filename string, revision string) *ModelWrapper { if modelID != "" { if w.Spec.Source.ModelHub == nil { w.Spec.Source.ModelHub = &coreapi.ModelHub{} @@ -57,6 +57,10 @@ func (w *ModelWrapper) ModelSourceWithModelID(modelID string, filename string) * if filename != "" { w.Spec.Source.ModelHub.Filename = &filename } + + if revision != "" { + w.Spec.Source.ModelHub.Revision = &revision + } } return w }