Skip to content

Commit

Permalink
helm: Add audioQnA e2e helm chart (#510)
Browse files Browse the repository at this point in the history
Signed-off-by: Lianhao Lu <[email protected]>
  • Loading branch information
lianhao authored Nov 4, 2024
1 parent b077d44 commit 9efacee
Show file tree
Hide file tree
Showing 12 changed files with 514 additions and 0 deletions.
23 changes: 23 additions & 0 deletions helm-charts/audioqna/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
33 changes: 33 additions & 0 deletions helm-charts/audioqna/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: v2
name: audioqna
description: The Helm chart to deploy AudioQnA
type: application
dependencies:
- name: asr
version: 1.0.0
repository: "file://../common/asr"
- name: whisper
version: 1.0.0
repository: "file://../common/whisper"
- name: tts
version: 1.0.0
repository: "file://../common/tts"
- name: speecht5
version: 1.0.0
repository: "file://../common/speecht5"
- name: tgi
version: 1.0.0
repository: "file://../common/tgi"
- name: llm-uservice
version: 1.0.0
repository: "file://../common/llm-uservice"
# Uncomment the following to enable UI when the UI image is ready on DockerHub
# - name: ui
# version: 1.0.0
# repository: "file://../common/ui"
# alias: audioqna-ui
version: 1.1.0
appVersion: "1.1"
60 changes: 60 additions & 0 deletions helm-charts/audioqna/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# AudioQnA

Helm chart for deploying AudioQnA service.

AudioQnA depends on the following micro services:

- [asr](../common/asr/README.md)
- [whisper](../common/whisper/README.md)
- [llm-uservice](../common/llm-uservice/README.md)
- [tgi](../common/tgi/README.md)
- [tts](../common/tts/README.md)
- [speecht5](../common/speecht5/README.md)

## Installing the Chart

To install the chart, run the following:

```console
cd GenAIInfra/helm-charts/
./update_dependency.sh
helm dependency update audioqna
export HFTOKEN="insert-your-huggingface-token-here"
export MODELDIR="/mnt/opea-models"
export MODELNAME="Intel/neural-chat-7b-v3-3"
# To run on Xeon
helm install audioqna audioqna --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} --set tgi.LLM_MODEL_ID=${MODELNAME}
# To run on Gaudi
#helm install audioqna audioqna --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} --set tgi.LLM_MODEL_ID=${MODELNAME} -f audioqna/gaudi-values.yaml
```

### IMPORTANT NOTE

1. Make sure your `MODELDIR` exists on the node where your workload is schedueled so you can cache the downloaded model for next time use. Otherwise, set `global.modelUseHostPath` to 'null' if you don't want to cache the model.

## Verify

To verify the installation, run the command `kubectl get pod` to make sure all pods are running.

Test the AudioQnA megaservice by recording a .wav file, encoding the file into the base64 format, and then sending the base64 string to the megaservice endpoint. The megaservice will return a spoken response as a base64 string. To listen to the response, decode the base64 string and save it as a .wav file.

### Verify the workload through curl command

Then run the command `kubectl port-forward svc/audioqna 3008:3008` to expose the service for access.

Open another terminal and run the following command to verify the service if working:

```console
curl http://localhost:3008/v1/audioqna \
-X POST \
-d '{"audio": "UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA", "max_tokens":64}' \
-H 'Content-Type: application/json' | sed 's/^"//;s/"$//' | base64 -d > output.wav
```

## Values

| Key | Type | Default | Description |
| ---------------- | ------ | --------------------------- | ------------------------------------------------------------------------ |
| image.repository | string | `"opea/audioqna"` | |
| service.port | string | `"3008"` | |
| tgi.LLM_MODEL_ID | string | `Intel/neural-chat-7b-v3-3` | Models id from https://huggingface.co/, or predownloaded model directory |
1 change: 1 addition & 0 deletions helm-charts/audioqna/ci-gaudi-values.yaml
1 change: 1 addition & 0 deletions helm-charts/audioqna/ci-values.yaml
43 changes: 43 additions & 0 deletions helm-charts/audioqna/gaudi-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

tgi:
accelDevice: "gaudi"
image:
repository: ghcr.io/huggingface/tgi-gaudi
tag: "2.0.5"
resources:
limits:
habana.ai/gaudi: 1
MAX_INPUT_LENGTH: "1024"
MAX_TOTAL_TOKENS: "2048"
CUDA_GRAPHS: ""
livenessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
readinessProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
startupProbe:
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 120

whisper:
image:
repository: opea/whisper-gaudi
tag: "latest"
resources:
limits:
habana.ai/gaudi: 1

speecht5:
image:
repository: opea/speecht5-gaudi
tag: "latest"
resources:
limits:
habana.ai/gaudi: 1
62 changes: 62 additions & 0 deletions helm-charts/audioqna/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "audioqna.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "audioqna.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "audioqna.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "audioqna.labels" -}}
helm.sh/chart: {{ include "audioqna.chart" . }}
{{ include "audioqna.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "audioqna.selectorLabels" -}}
app.kubernetes.io/name: {{ include "audioqna.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "audioqna.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "audioqna.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
85 changes: 85 additions & 0 deletions helm-charts/audioqna/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "audioqna.fullname" . }}
labels:
{{- include "audioqna.labels" . | nindent 4 }}
app: {{ include "audioqna.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "audioqna.selectorLabels" . | nindent 6 }}
app: {{ include "audioqna.fullname" . }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "audioqna.selectorLabels" . | nindent 8 }}
app: {{ include "audioqna.fullname" . }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Release.Name }}
env:
- name: LLM_SERVICE_HOST_IP
value: {{ include "llm-uservice.fullname" (index .Subcharts "llm-uservice") }}
- name: LLM_SERVICE_PORT
value: {{ index .Values "llm-uservice" "service" "port" | quote }}
- name: ASR_SERVICE_HOST_IP
value: {{ include "asr.fullname" (index .Subcharts "asr") }}
- name: ASR_SERVICE_PORT
value: {{ index .Values "asr" "service" "port" | quote }}
- name: TTS_SERVICE_HOST_IP
value: {{ include "tts.fullname" (index .Subcharts "tts") }}
- name: TTS_SERVICE_PORT
value: {{ index .Values "tts" "service" "port" | quote }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /tmp
name: tmp
ports:
- name: audioqna
containerPort: {{ .Values.port }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: tmp
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.evenly_distributed }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
{{- include "audioqna.selectorLabels" . | nindent 14 }}
app: {{ include "audioqna.fullname" . }}
{{- end }}
Loading

0 comments on commit 9efacee

Please sign in to comment.