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

Huggingface model deployer support #157

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/book/stacks/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ as can a list of components that are coming soon.
| Experiment Tracker | mlflow |
| Orchestrator | kubeflow, kubernetes, sagemaker, skypilot, tekton |
| MLOps Platform | zenml |
| Model Deployer | seldon |
| Model Deployer | seldon, huggingface |
| Step Operator | sagemaker |

## Coming Soon!
Expand Down
2 changes: 1 addition & 1 deletion docs/book/stacks/gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and cannot be created without one.
| Experiment Tracker | mlflow |
| Orchestrator | kubeflow, kubernetes, skypilot, tekton, vertex |
| MLOps Platform | zenml |
| Model Deployer | seldon |
| Model Deployer | seldon, huggingface |
| Step Operator | vertex |

## Coming Soon!
Expand Down
2 changes: 1 addition & 1 deletion docs/book/stacks/k3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ as can a list of components that are coming soon.
| Experiment Tracker | mlflow |
| Orchestrator | kubeflow, kubernetes, sagemaker, tekton |
| MLOps Platform | zenml |
| Model Deployer | seldon |
| Model Deployer | seldon, huggingface |

## Coming Soon!

Expand Down
2 changes: 1 addition & 1 deletion src/mlstacks/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"vertex",
],
"mlops_platform": ["zenml"],
"model_deployer": ["seldon"],
"model_deployer": ["seldon", "huggingface"],
"step_operator": ["sagemaker", "vertex"],
}
ALLOWED_COMPONENT_TYPES: Dict[str, Dict[str, List[str]]] = {
Expand Down
1 change: 1 addition & 0 deletions src/mlstacks/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ComponentFlavorEnum(str, Enum):

AWS = "aws"
GCP = "gcp"
HUGGINGFACE = "huggingface"
KUBEFLOW = "kubeflow"
KUBERNETES = "kubernetes"
MINIO = "minio"
Expand Down
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/aws-modular/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ data "external" "get_cluster_auth" {
depends_on = [
aws_eks_cluster.cluster
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/aws-modular/istio.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module "istio" {
]

chart_version = local.istio.version
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/aws-modular/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ locals {
namespace = "seldon-system"
workloads_namespace = "zenml-workloads-seldon"
service_account_name = "seldon"
}
}

zenml = {
version = ""
Expand Down
7 changes: 7 additions & 0 deletions src/mlstacks/terraform/aws-modular/output_file.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ resource "local_file" "stack_file" {
flavor: seldon
name: eks_seldon_model_deployer
configuration: {"kubernetes_context": "${aws_eks_cluster.cluster[0].arn}", "kubernetes_namespace": "${local.seldon.workloads_namespace}", "base_url": "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}"}}
%{endif}
%{if var.enable_model_deployer_huggingface}
model_deployer:
id: ${uuid()}
flavor: huggingface
name: eks_huggingface_model_deployer
configuration: {"kubernetes_context": "${aws_eks_cluster.cluster[0].arn}", "kubernetes_namespace": "${local.huggingface.workloads_namespace}", "base_url": "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}"}}
Comment on lines +84 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs updating as we're no longer using EKS for this etc..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strickvl Thank you for the review! I understood everything else but for this part, Could you please provide more guidance or resources on how to do this part?

%{endif}
ADD
filename = "./aws_modular_stack_${replace(substr(timestamp(), 0, 16), ":", "_")}.yaml"
Expand Down
28 changes: 10 additions & 18 deletions src/mlstacks/terraform/aws-modular/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,6 @@ output "experiment_tracker_configuration" {
}) : ""
}

# if seldon is enabled, set the model deployer outputs to the seldon values
# otherwise, set the model deployer outputs to empty strings
output "model_deployer_id" {
value = var.enable_model_deployer_seldon ? uuid() : ""
}
output "model_deployer_flavor" {
value = var.enable_model_deployer_seldon ? "seldon" : ""
}
output "model_deployer_name" {
value = var.enable_model_deployer_seldon ? "eks_seldon_model_deployer_${random_string.unique.result}" : ""
}
output "model_deployer_configuration" {
value = var.enable_model_deployer_seldon ? jsonencode({
kubernetes_context = "${aws_eks_cluster.cluster[0].arn}"
kubernetes_namespace = local.seldon.workloads_namespace
base_url = "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}"
}) : ""
}

# if sagemaker is enabled as step operator, set the step operator outputs to the sagemaker values
# otherwise, set the step operator outputs to empty strings
Expand Down Expand Up @@ -162,6 +144,16 @@ output "seldon-base-url" {
value = var.enable_model_deployer_seldon ? "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}" : null
}

# output for huggingface model deployer
output "huggingface-workload-namespace" {
value = var.enable_model_deployer_huggingface ? local.huggingface.workloads_namespace : null
description = "The namespace created for hosting your Huggingface workloads"
}

output "huggingface-base-url" {
value = var.enable_model_deployer_huggingface ? "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}" : null
}

# output the name of the stack YAML file created
output "stack-yaml-path" {
value = local_file.stack_file.filename
Expand Down
15 changes: 15 additions & 0 deletions src/mlstacks/terraform/aws-modular/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ variable "enable_model_deployer_seldon" {
description = "Enable Seldon deployment"
default = false
}
variable "enable_model_deployer_huggingface" {
description = "Enable Huggingface deployment"
default = false
}
variable "enable_step_operator_sagemaker" {
description = "Enable SageMaker as step operator"
default = false
Expand All @@ -57,6 +61,17 @@ variable "region" {
default = "eu-west-1"
}

# variables for huggingface model model deployer
variable "huggingface_token"{
description = "The Hugging Face authentication token."
default = "huggingfaceauthenticationtoken"
}

variable "huggingface_namespace" {
description = "The namespace where the Inference Endpoint will be created."
default = "huggingfacenamespace"
} cb cb

# variables for the MLflow tracking server
variable "mlflow-artifact-S3-access-key" {
description = "Your AWS access key for using S3 as MLflow artifact store"
Expand Down
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/gcp-modular/gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,4 @@ resource "google_project_iam_binding" "vertex-ai-user" {
members = [
"serviceAccount:${google_service_account.gke-service-account[0].email}",
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/gcp-modular/istio.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ module "istio" {
]

chart_version = local.istio.version
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/gcp-modular/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ resource "google_service_account_iam_member" "k8s-workload-access" {
depends_on = [
kubernetes_namespace.k8s-workloads,
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/gcp-modular/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ locals {
workloads_namespace = "zenml-workloads-seldon"
service_account_name = "seldon"
}

zenml = {
version = ""
database_ssl_ca = ""
Expand Down
7 changes: 7 additions & 0 deletions src/mlstacks/terraform/gcp-modular/output_file.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ resource "local_file" "stack_file" {
flavor: seldon
name: gke_seldon
configuration: {"kubernetes_context": "gke_${local.prefix}-${local.gke.cluster_name}", "kubernetes_namespace": "${local.seldon.workloads_namespace}", "base_url": "http://${module.istio[0].ingress-ip-address}:${module.istio[0].ingress-port}"}
%{endif}
%{if var.enable_model_deployer_huggingface}
model_deployer:
id: ${uuid()}
flavor: huggingface
name: eks_huggingface_model_deployer
configuration: {"kubernetes_context": "${aws_eks_cluster.cluster[0].arn}", "kubernetes_namespace": "${local.huggingface.workloads_namespace}", "base_url": "http://${module.istio[0].ingress-hostname}:${module.istio[0].ingress-port}"}}
%{endif}
ADD
filename = "./gcp_modular_stack_${replace(substr(timestamp(), 0, 16), ":", "_")}.yaml"
Expand Down
19 changes: 0 additions & 19 deletions src/mlstacks/terraform/gcp-modular/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@ output "experiment_tracker_configuration" {
}) : ""
}

# if seldon is enabled, set the model deployer outputs to the seldon values
# otherwise, set the model deployer outputs to empty strings
output "model_deployer_id" {
value = var.enable_model_deployer_seldon ? uuid() : ""
}
output "model_deployer_flavor" {
value = var.enable_model_deployer_seldon ? "seldon" : ""
}
output "model_deployer_name" {
value = var.enable_model_deployer_seldon ? "gke_seldon_model_deployer_${random_string.unique.result}" : ""
}
output "model_deployer_configuration" {
value = var.enable_model_deployer_seldon ? jsonencode({
kubernetes_context = "gke_${var.project_id}_${var.region}_${local.prefix}-${local.gke.cluster_name}"
kubernetes_namespace = local.seldon.workloads_namespace
base_url = "http://${module.istio[0].ingress-ip-address}:${module.istio[0].ingress-port}"
}) : ""
}

# project id
output "project-id" {
value = var.project_id
Expand Down
14 changes: 14 additions & 0 deletions src/mlstacks/terraform/gcp-modular/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ variable "enable_model_deployer_seldon" {
description = "Enable Seldon deployment"
default = false
}
variable "enable_model_deployer_huggingface" {
description = "Enable Huggingface deployment"
default = false
}
variable "enable_step_operator_vertex" {
description = "Enable VertexAI Step Operator"
default = false
Expand All @@ -57,6 +61,16 @@ variable "project_id" {
default = ""
}

# variables for huggingface model model deployer
variable "huggingface_token"{
description = "The Hugging Face authentication token."
default = "huggingfaceauthenticationtoken"
}

variable "huggingface_namespace" {
description = "The namespace where the Inference Endpoint will be created."
default = "huggingfacenamespace"
}

# variables for the MLflow tracking server
variable "mlflow_bucket" {
Expand Down
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/gcp-modular/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ module "vpc" {
next_hop_internet = "true"
},
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/helm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ provider "helm" {
var.enable_orchestrator_tekton || var.enable_orchestrator_kubernetes ||
var.enable_model_deployer_seldon || var.enable_experiment_tracker_mlflow || var.enable_artifact_store || var.enable_zenml) ? k3d_cluster.zenml-cluster[0].credentials.0.cluster_ca_certificate : ""
}
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/istio.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module "istio" {
]

chart_version = local.istio.version
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/k3d.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ resource "k3d_cluster" "zenml-cluster" {
depends_on = [
k3d_registry.zenml-registry,
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/kubeflow.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ module "kubeflow-pipelines" {
ingress_host = (var.enable_model_deployer_seldon) ? "${local.kubeflow.ingress_host_prefix}.${module.istio[0].ingress-ip-address}.nip.io" : "${local.kubeflow.ingress_host_prefix}.${module.nginx-ingress[0].ingress-ip-address}.nip.io"
tls_enabled = false
istio_enabled = (var.enable_model_deployer_seldon) ? true : false
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ resource "kubernetes_namespace" "k8s-workloads" {
depends_on = [
k3d_cluster.zenml-cluster,
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ locals {
workloads_namespace = "zenml-workloads-seldon"
service_account_name = "seldon"
}

common_tags = {
"managedBy" = "terraform"
"environment" = "dev"
Expand Down
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/minio.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ resource "minio_s3_bucket" "zenml_bucket" {
module.nginx-ingress,
module.istio,
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/mlflow.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ resource "minio_s3_bucket" "mlflow_bucket" {
module.nginx-ingress,
module.istio,
]
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/nginx_ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ module "nginx-ingress" {
]

chart_version = local.nginx_ingress.version
}
}
2 changes: 1 addition & 1 deletion src/mlstacks/terraform/k3d-modular/output_stack.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ resource "local_file" "stack_file" {
%{endif}
ADD
filename = "./k3d_stack_${replace(substr(timestamp(), 0, 16), ":", "_")}.yaml"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ environments:
%{endif}
ADD
filename = "./k3d_test_framework_cfg.yaml"
}
}
Loading
Loading