Repository: kaito-project/kaito
Pull request #986: feat: Add Annotation Bypass GPU Mem check
Author: login: ishaansehgal99
Labels: name: Review effort 3/5
Created: 2025-04-04T00:57:38Z | Merged: 2025-04-05T02:08:46Z

**Reason for Change**:
Add a workspace annotation to bypass validation checks for the minimum GPU memory required by their workspace.


Diff:
diff --git a/api/v1alpha1/labels.go b/api/v1alpha1/labels.go
index 99b9a549a9..c8628f8322 100644
--- a/api/v1alpha1/labels.go
+++ b/api/v1alpha1/labels.go
@@ -39,6 +39,9 @@ const (
 
 	// AnnotationWorkspaceRuntime is the annotation for runtime selection.
 	AnnotationWorkspaceRuntime = KAITOPrefix + "runtime"
+
+	// AnnotationBypassResourceChecks allows bypassing resource requirement checks like GPU memory.
+	AnnotationBypassResourceChecks = KAITOPrefix + "bypass-resource-checks"
 )
 
 // GetWorkspaceRuntimeName returns the runtime name of the workspace.
diff --git a/api/v1alpha1/workspace_validation.go b/api/v1alpha1/workspace_validation.go
index 1a8dec1f44..85fedf72e6 100644
--- a/api/v1alpha1/workspace_validation.go
+++ b/api/v1alpha1/workspace_validation.go
@@ -55,8 +55,16 @@ func (w *Workspace) Validate(ctx context.Context) (errs *apis.FieldError) {
 		klog.InfoS("Validate creation", "workspace", fmt.Sprintf("%s/%s", w.Namespace, w.Name))
 		errs = errs.Also(w.validateCreate().ViaField("spec"))
 		if w.Inference != nil {
+			// Check if the bypass resource checks annotation is set
+			bypassResourceChecks := false
+			if w.GetAnnotations() != nil {
+				if _, exists := w.GetAnnotations()[AnnotationBypassResourceChecks]; exists {
+					bypassResourceChecks = true
+				}
+			}
+
 			// TODO: Add Adapter Spec Validation - Including DataSource Validation for Adapter
-			errs = errs.Also(w.Resource.validateCreateWithInference(w.Inference).ViaField("resource"),
+			errs = errs.Also(w.Resource.validateCreateWithInference(w.Inference, bypassResourceChecks).ViaField("resource"),
 				w.Inference.validateCreate(ctx, w.Namespace).ViaField("inference"))
 		}
 		if w.Tuning != nil {
@@ -290,7 +298,7 @@ func (r *ResourceSpec) validateCreateWithTuning(tuning *TuningSpec) (errs *apis.
 	return errs
 }
 
-func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec) (errs *apis.FieldError) {
+func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec, bypassResourceChecks bool) (errs *apis.FieldError) {
 	var presetName string
 	if inference.Preset != nil {
 		presetName = strings.ToLower(string(inference.Preset.Name))
@@ -325,42 +333,57 @@ func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec) (er
 
 			// Separate the checks for specific error messages
 			if machineTotalNumGPUs.Cmp(modelGPUCount) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
-						instanceType,
-						machineTotalNumGPUs.String(),
-						presetName,
-						modelGPUCount.Value(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient number of GPUs detected but continuing due to bypass flag. Instance type %s provides %s, but preset %s requires at least %d",
+						instanceType, machineTotalNumGPUs.String(), presetName, modelGPUCount.Value())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
+							instanceType,
+							machineTotalNumGPUs.String(),
+							presetName,
+							modelGPUCount.Value(),
+						),
+						"instanceType",
+					))
+				}
 			}
 
 			if machinePerGPUMemory.Cmp(modelPerGPUMemory) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient per GPU memory: Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
-						instanceType,
-						machinePerGPUMemory.String(),
-						presetName,
-						modelPerGPUMemory.String(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient per GPU memory but continuing due to bypass flag. Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
+						instanceType, machinePerGPUMemory.String(), presetName, modelPerGPUMemory.String())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient per GPU memory: Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
+							instanceType,
+							machinePerGPUMemory.String(),
+							presetName,
+							modelPerGPUMemory.String(),
+						),
+						"instanceType",
+					))
+				}
 			}
 
 			if machineTotalGPUMem.Cmp(modelTotalGPUMemory) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient total GPU memory: Instance type %s has a total of %s, but preset %s requires at least %s",
-						instanceType,
-						machineTotalGPUMem.String(),
-						presetName,
-						modelTotalGPUMemory.String(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient total GPU memory detected but continuing due to bypass flag. Instance type %s has a total of %s, but preset %s requires at least %s",
+						instanceType, machineTotalGPUMem.String(), presetName, modelTotalGPUMemory.String())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient total GPU memory: Instance type %s has a total of %s, but preset %s requires at least %s",
+							instanceType,
+							machineTotalGPUMem.String(),
+							presetName,
+							modelTotalGPUMemory.String(),
+						),
+						"instanceType",
+					))
+				}
 			}
 		}
 	} else {
diff --git a/api/v1alpha1/workspace_validation_test.go b/api/v1alpha1/workspace_validation_test.go
index a49648af8f..e974ae11e3 100644
--- a/api/v1alpha1/workspace_validation_test.go
+++ b/api/v1alpha1/workspace_validation_test.go
@@ -420,7 +420,7 @@ func TestResourceSpecValidateCreate(t *testing.T) {
 				totalGPUMemoryRequirement = tc.modelTotalGPUMemory
 				perGPUMemoryRequirement = tc.modelPerGPUMemory
 
-				errs := tc.resourceSpec.validateCreateWithInference(&spec)
+				errs := tc.resourceSpec.validateCreateWithInference(&spec, false)
 				hasErrs := errs != nil
 				if hasErrs != tc.expectErrs {
 					t.Errorf("validateCreate() errors = %v, expectErrs %v", errs, tc.expectErrs)
diff --git a/api/v1beta1/labels.go b/api/v1beta1/labels.go
index 501adca1f5..7fe9d5b992 100644
--- a/api/v1beta1/labels.go
+++ b/api/v1beta1/labels.go
@@ -30,6 +30,9 @@ const (
 
 	// AnnotationWorkspaceRuntime is the annotation for runtime selection.
 	AnnotationWorkspaceRuntime = KAITOPrefix + "runtime"
+
+	// AnnotationBypassResourceChecks allows bypassing resource requirement checks like GPU memory.
+	AnnotationBypassResourceChecks = KAITOPrefix + "bypass-resource-checks"
 )
 
 // GetWorkspaceRuntimeName returns the runtime name of the workspace.
diff --git a/api/v1beta1/workspace_validation.go b/api/v1beta1/workspace_validation.go
index b2b4653c08..65dee41815 100644
--- a/api/v1beta1/workspace_validation.go
+++ b/api/v1beta1/workspace_validation.go
@@ -55,8 +55,16 @@ func (w *Workspace) Validate(ctx context.Context) (errs *apis.FieldError) {
 		klog.InfoS("Validate creation", "workspace", fmt.Sprintf("%s/%s", w.Namespace, w.Name))
 		errs = errs.Also(w.validateCreate().ViaField("spec"))
 		if w.Inference != nil {
+			// Check if the bypass resource checks annotation is set
+			bypassResourceChecks := false
+			if w.GetAnnotations() != nil {
+				if _, exists := w.GetAnnotations()[AnnotationBypassResourceChecks]; exists {
+					bypassResourceChecks = true
+				}
+			}
+
 			// TODO: Add Adapter Spec Validation - Including DataSource Validation for Adapter
-			errs = errs.Also(w.Resource.validateCreateWithInference(w.Inference).ViaField("resource"),
+			errs = errs.Also(w.Resource.validateCreateWithInference(w.Inference, bypassResourceChecks).ViaField("resource"),
 				w.Inference.validateCreate(ctx, w.Namespace).ViaField("inference"))
 		}
 		if w.Tuning != nil {
@@ -290,7 +298,7 @@ func (r *ResourceSpec) validateCreateWithTuning(tuning *TuningSpec) (errs *apis.
 	return errs
 }
 
-func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec) (errs *apis.FieldError) {
+func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec, bypassResourceChecks bool) (errs *apis.FieldError) {
 	var presetName string
 	if inference.Preset != nil {
 		presetName = strings.ToLower(string(inference.Preset.Name))
@@ -325,42 +333,57 @@ func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec) (er
 
 			// Separate the checks for specific error messages
 			if machineTotalNumGPUs.Cmp(modelGPUCount) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
-						instanceType,
-						machineTotalNumGPUs.String(),
-						presetName,
-						modelGPUCount.Value(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient number of GPUs detected but continuing due to bypass flag. Instance type %s provides %s, but preset %s requires at least %d",
+						instanceType, machineTotalNumGPUs.String(), presetName, modelGPUCount.Value())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
+							instanceType,
+							machineTotalNumGPUs.String(),
+							presetName,
+							modelGPUCount.Value(),
+						),
+						"instanceType",
+					))
+				}
 			}
 
 			if machinePerGPUMemory.Cmp(modelPerGPUMemory) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient per GPU memory: Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
-						instanceType,
-						machinePerGPUMemory.String(),
-						presetName,
-						modelPerGPUMemory.String(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient per GPU memory but continuing due to bypass flag. Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
+						instanceType, machinePerGPUMemory.String(), presetName, modelPerGPUMemory.String())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient per GPU memory: Instance type %s provides %s per GPU, but preset %s requires at least %s per GPU",
+							instanceType,
+							machinePerGPUMemory.String(),
+							presetName,
+							modelPerGPUMemory.String(),
+						),
+						"instanceType",
+					))
+				}
 			}
 
 			if machineTotalGPUMem.Cmp(modelTotalGPUMemory) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient total GPU memory: Instance type %s has a total of %s, but preset %s requires at least %s",
-						instanceType,
-						machineTotalGPUMem.String(),
-						presetName,
-						modelTotalGPUMemory.String(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
+					klog.Warningf("Bypassing resource check: Insufficient total GPU memory detected but continuing due to bypass flag. Instance type %s has a total of %s, but preset %s requires at least %s",
+						instanceType, machineTotalGPUMem.String(), presetName, modelTotalGPUMemory.String())
+				} else {
+					errs = errs.Also(apis.ErrInvalidValue(
+						fmt.Sprintf(
+							"Insufficient total GPU memory: Instance type %s has a total of %s, but preset %s requires at least %s",
+							instanceType,
+							machineTotalGPUMem.String(),
+							presetName,
+							modelTotalGPUMemory.String(),
+						),
+						"instanceType",
+					))
+				}
 			}
 		}
 	} else {
diff --git a/api/v1beta1/workspace_validation_test.go b/api/v1beta1/workspace_validation_test.go
index 101e43de27..f4dd49b539 100644
--- a/api/v1beta1/workspace_validation_test.go
+++ b/api/v1beta1/workspace_validation_test.go
@@ -420,7 +420,7 @@ func TestResourceSpecValidateCreate(t *testing.T) {
 				totalGPUMemoryRequirement = tc.modelTotalGPUMemory
 				perGPUMemoryRequirement = tc.modelPerGPUMemory
 
-				errs := tc.resourceSpec.validateCreateWithInference(&spec)
+				errs := tc.resourceSpec.validateCreateWithInference(&spec, false)
 				hasErrs := errs != nil
 				if hasErrs != tc.expectErrs {
 					t.Errorf("validateCreate() errors = %v, expectErrs %v", errs, tc.expectErrs)
diff --git a/examples/README.md b/examples/README.md
index e9becab0dd..162276c512 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,2 +1,28 @@
 # Notes:
-For **testing** purposes, users can add the `kaito.sh/enablelb: "True"` annotation to the workspace custom resource. As a result, a `loadbalancer` type service will be created for the inference service with a public IP being assigned. However, this is **NOT** recommended for production use. An [ingress controller](https://learn.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-cli) is recommended to expose the service to public.
+
+### GPU Resource Requirement Bypass
+To bypass GPU memory requirement checks, annotate your workspace resource as follows:
+```yaml
+apiVersion: kaito.sh/v1alpha1
+kind: Workspace
+metadata:
+  name: my-workspace
+  annotations:
+    kaito.sh/bypass-resource-checks: "true"
+  # ... rest of the workspace spec
+```
+> Caution: Using this annotation may lead to degraded performance or out-of-memory errors if GPU resources are insufficient for your model. Warnings will be logged accordingly.
+
+---
+
+### Exposing Service via LoadBalancer (Testing Only)
+
+For **testing** purposes, you may annotate your workspace resource with `kaito.sh/enablelb: "true"` to automatically create a `LoadBalancer` type service with a public IP for the inference service:
+
+```yaml
+metadata:
+  annotations:
+    kaito.sh/enablelb: "true"
+```
+> Important: This approach is **NOT** recommended for production environments. For production scenarios, use an [Ingress Controller](https://learn.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-cli) to safely expose the service.
+


Reviews:
user: login: Fei-Guo
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-04T01:45:05Z
user: login: Fei-Guo
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-05T02:08:38Z

Review comments:
diff_hunk: @@ -55,8 +55,17 @@ func (w *Workspace) Validate(ctx context.Context) (errs *apis.FieldError) {
 		klog.InfoS("Validate creation", "workspace", fmt.Sprintf("%s/%s", w.Namespace, w.Name))
 		errs = errs.Also(w.validateCreate().ViaField("spec"))
 		if w.Inference != nil {
+			// Check if the bypass resource checks annotation is set
+			bypassResourceChecks := false
+			if w.GetAnnotations() != nil {
+				if _, exists := w.GetAnnotations()[AnnotationBypassResourceChecks]; exists {
+					bypassResourceChecks = true
+					klog.Warningf("Bypassing resource requirement checks due to annotation %s", AnnotationBypassResourceChecks)
path: api/v1beta1/workspace_validation.go
user: login: Fei-Guo
body: I think this log line is not needed. 
created_at: 2025-04-04T01:42:00Z
author_association: COLLABORATOR
diff_hunk: @@ -325,42 +334,57 @@ func (r *ResourceSpec) validateCreateWithInference(inference *InferenceSpec) (er
 
 			// Separate the checks for specific error messages
 			if machineTotalNumGPUs.Cmp(modelGPUCount) < 0 {
-				errs = errs.Also(apis.ErrInvalidValue(
-					fmt.Sprintf(
-						"Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
-						instanceType,
-						machineTotalNumGPUs.String(),
-						presetName,
-						modelGPUCount.Value(),
-					),
-					"instanceType",
-				))
+				if bypassResourceChecks {
path: api/v1beta1/workspace_validation.go
user: login: Fei-Guo
body: You can enhance this log line, saying the bypassresourcecheck flag is set, hence a warning is generated, not blocking the mutation. The same applies to the next two new logs. 
created_at: 2025-04-04T01:43:19Z
author_association: COLLABORATOR

PR comments:
user: login: kaito-pr-agent[bot]
created_at: 2025-04-04T00:57:51Z
body: ## Title

#### (Describe updated until commit https://github.com/kaito-project/kaito/commit/e3e2280094285897edecbeb748061c03c5efe510)


feat: Add Annotation Bypass GPU Mem check

___
### **User description**
**Reason for Change**:
Add a workspace annotation to bypass validation checks for the minimum GPU memory required by their workspace.


___

### **PR Type**
Enhancement


___

### **Description**
- Added `AnnotationBypassResourceChecks` to allow bypassing resource requirement checks like GPU memory.

- Updated validation logic to check for the bypass resource checks annotation before enforcing GPU memory requirements.

- Enhanced README.md with instructions on how to bypass GPU memory requirement checks and expose services via LoadBalancer.


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>4 files</summary><table>
<tr>
  <td><strong>labels.go</strong><dd><code>Add AnnotationBypassResourceChecks</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-099881e12ca84a9271fd65c507940e6a57271309f2177a3d8387b169b4d91154">+3/-0</a>&nbsp; &nbsp; &nbsp; </td>

</tr>

<tr>
  <td><strong>workspace_validation.go</strong><dd><code>Update validation logic to include bypass resource checks</code></dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-5aa8d95205b91001e903b72a7a9dfb992d1acbeae62204197db42d7c684d811e">+55/-32</a>&nbsp; </td>

</tr>

<tr>
  <td><strong>labels.go</strong><dd><code>Add AnnotationBypassResourceChecks</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-9224cc1393c03b0f2c1df3ec9fa029113dc62a69d905cd1a3afbb10676657eb7">+3/-0</a>&nbsp; &nbsp; &nbsp; </td>

</tr>

<tr>
  <td><strong>workspace_validation.go</strong><dd><code>Update validation logic to include bypass resource checks</code></dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-ff810030efa090347e63f5a61e4344f94c6f3167ace34bfcc8f602249acd1959">+55/-32</a>&nbsp; </td>

</tr>
</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>2 files</summary><table>
<tr>
  <td><strong>workspace_validation_test.go</strong><dd><code>Update test cases to reflect changes in validation logic</code>&nbsp; </dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-40361cf72c705b9ed5e31c558e6ef9fa52e32b75118ae5d14d875513614fd686">+1/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>

<tr>
  <td><strong>workspace_validation_test.go</strong><dd><code>Update test cases to reflect changes in validation logic</code>&nbsp; </dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-f7f7c3213c1c9eace61d77a0dcd6d091f3ea17c0b81ba8cb32ad416bdf09f888">+1/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table>
<tr>
  <td><strong>README.md</strong><dd><code>Add instructions for bypassing GPU memory requirement checks and </code><br><code>exposing services via LoadBalancer</code></dd></td>
  <td><a href="https://github.com/kaito-project/kaito/pull/986/files#diff-49aaa2819e35a856818ecec8c9fa7e1c79ad028d3f44bd749736353cfb51bac9">+27/-1</a>&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

___

> <details> <summary>  Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details>
author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-04T00:57:58Z
body: ## PR Reviewer Guide 🔍

#### (Review updated until commit https://github.com/kaito-project/kaito/commit/e3e2280094285897edecbeb748061c03c5efe510)


Here are some key observations to aid the review process:

<table>
<tr><td>&nbsp;<strong>Estimated effort to review</strong>: 3 🔵🔵🔵⚪⚪</td></tr>
<tr><td>🧪&nbsp;<strong>PR contains tests</strong></td></tr>
<tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr>
<tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br>

<details><summary><a href='https://github.com/kaito-project/kaito/pull/986/files#diff-5aa8d95205b91001e903b72a7a9dfb992d1acbeae62204197db42d7c684d811eR49-R55'><strong>Potential Logic Error</strong></a>

The logic for handling the bypass resource checks annotation seems incomplete. It sets `bypassResourceChecks` to `false` initially and then updates it only if the annotation exists. However, the function `validateCreateWithInference` still calls `validateCreateWithInference` without passing the `bypassResourceChecks` parameter, which might lead to incorrect behavior.
</summary>

```go
errmsgs := validation.IsDNS1123Label(w.Name)
if len(errmsgs) > 0 {
	errs = errs.Also(apis.ErrInvalidValue(strings.Join(errmsgs, ", "), "name"))
}
base := apis.GetBaseline(ctx)
if base == nil {
	klog.InfoS("Validate creation", "workspace", fmt.Sprintf("%s/%s", w.Namespace, w.Name))
```

</details>

<details><summary><a href='https://github.com/kaito-project/kaito/pull/986/files#diff-ff810030efa090347e63f5a61e4344f94c6f3167ace34bfcc8f602249acd1959R49-R55'><strong>Potential Logic Error</strong></a>

The logic for handling the bypass resource checks annotation seems incomplete. It sets `bypassResourceChecks` to `false` initially and then updates it only if the annotation exists. However, the function `validateCreateWithInference` still calls `validateCreateWithInference` without passing the `bypassResourceChecks` parameter, which might lead to incorrect behavior.
</summary>

```go
errmsgs := validation.IsDNS1123Label(w.Name)
if len(errmsgs) > 0 {
	errs = errs.Also(apis.ErrInvalidValue(strings.Join(errmsgs, ", "), "name"))
}
base := apis.GetBaseline(ctx)
if base == nil {
	klog.InfoS("Validate creation", "workspace", fmt.Sprintf("%s/%s", w.Namespace, w.Name))
```

</details>

</td></tr>
</table>

author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-04T00:58:09Z
body: ## PR Code Suggestions ✨

<!-- 393e0da -->

Explore these optional code suggestions:

<table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>General</td>
<td>



<details><summary>Remove redundant checks for bypassing resource requirements</summary>

___


**Simplify the conditional logic by removing redundant checks.**

[api/v1beta1/workspace_validation.go [333-352]](https://github.com/kaito-project/kaito/pull/986/files#diff-ff810030efa090347e63f5a61e4344f94c6f3167ace34bfcc8f602249acd1959R333-R352)

```diff
-if machineTotalNumGPUs.Cmp(modelGPUCount) < 0 {
-    if bypassResourceChecks {
-        klog.Warningf("Insufficient number of GPUs (bypassed): Instance type %s provides %s, but preset %s requires at least %d",
-            instanceType, machineTotalNumGPUs.String(), presetName, modelGPUCount.Value())
-    } else {
-        errs = errs.Also(apis.ErrInvalidValue(
-            fmt.Sprintf(
-                "Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
-                instanceType,
-                machineTotalNumGPUs.String(),
-                presetName,
-                modelGPUCount.Value(),
-            ),
-            "instanceType",
-        ))
-    }
+if machineTotalNumGPUs.Cmp(modelGPUCount) < 0 && !bypassResourceChecks {
+    errs = errs.Also(apis.ErrInvalidValue(
+        fmt.Sprintf(
+            "Insufficient number of GPUs: Instance type %s provides %s, but preset %s requires at least %d",
+            instanceType,
+            machineTotalNumGPUs.String(),
+            presetName,
+            modelGPUCount.Value(),
+        ),
+        "instanceType",
+    ))
 }
```
<details><summary>Suggestion importance[1-10]: 5</summary>

__

Why: The suggestion simplifies the conditional logic by removing redundant checks, making the code cleaner and easier to understand.


</details></details></td><td align=center>Low

</td></tr></tr></tbody></table>


author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-04T01:12:12Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/9bdda0b74eb420ae16775933a3fc314e625459b6
author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-05T01:00:34Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/bb6614fb4f36398004d7fc337fe3185be12e0213
author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-05T01:02:03Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/038abea3e832b287f5be61eacf4dc859df96aa98
author_association: CONTRIBUTOR
user: login: codecov[bot]
created_at: 2025-04-05T01:06:04Z
body: ## [Codecov](https://app.codecov.io/gh/kaito-project/kaito/pull/986?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaito-project) Report
Attention: Patch coverage is `85.10638%` with `14 lines` in your changes missing coverage. Please review.

```diff
@@            Coverage Diff             @@
##             main     #986      +/-   ##
==========================================
- Coverage   60.05%   53.45%   -6.60%     
==========================================
  Files          64       51      -13     
  Lines        6784     6055     -729     
==========================================
- Hits         4074     3237     -837     
- Misses       2502     2602     +100     
- Partials      208      216       +8     
```

| [Components](https://app.codecov.io/gh/kaito-project/kaito/pull/986/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaito-project) | Coverage Δ | |
|---|---|---|
| [workspace](https://app.codecov.io/gh/kaito-project/kaito/pull/986/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaito-project) | `51.86% <35.00%> (-4.81%)` | :arrow_down: |
| [presets](https://app.codecov.io/gh/kaito-project/kaito/pull/986/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaito-project) | `91.55% <ø> (+4.96%)` | :arrow_up: |
| [main](https://app.codecov.io/gh/kaito-project/kaito/pull/986/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kaito-project) | `∅ <ø> (∅)` | |

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
author_association: NONE
user: login: kaito-pr-agent[bot]
created_at: 2025-04-05T01:14:06Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/da70f2e6a391ea4f3eab8578a12c9d2790b6fc3a
author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-05T01:15:14Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/89a2384ef42608aafdc394889587ee14a0e1d6dc
author_association: CONTRIBUTOR
user: login: kaito-pr-agent[bot]
created_at: 2025-04-05T01:19:59Z
body: **[Persistent review](https://github.com/kaito-project/kaito/pull/986#issuecomment-2777307154)** updated to latest commit https://github.com/kaito-project/kaito/commit/e3e2280094285897edecbeb748061c03c5efe510
author_association: CONTRIBUTOR