Skip to content

Commit

Permalink
llm redis
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheng422 committed Nov 13, 2023
1 parent ab483e7 commit b3b3e6d
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 22 deletions.
79 changes: 57 additions & 22 deletions redhat/ocp4/4.13/4.13.gpu.llm.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ done
mkdir -p /var/wzh-local-pv/dynamic
chcon -Rt container_file_t /var/wzh-local-pv/

# delete content
for i in 13 14 17; do
rm -rf /var/wzh-local-pv/static/$i/*
done

# on helper
cat << EOF > ${BASE_DIR}/data/install/local-sc.yaml
---
Expand Down Expand Up @@ -831,7 +836,12 @@ oc adm policy add-scc-to-user redis-enterprise-scc-v2 system:serviceaccount:llm-

```bash

cat << EOF > ${BASE_DIR}/tmp/redis-cluster.yaml
# clear directory, and re-apply the scc
# if you want to re-install redis
oc adm policy add-scc-to-user redis-enterprise-scc-v2 system:serviceaccount:llm-demo:redis-enterprise-operator
oc adm policy add-scc-to-user redis-enterprise-scc-v2 system:serviceaccount:llm-demo:rec

cat << EOF > ${BASE_DIR}/data/install/redis-cluster.yaml
apiVersion: app.redislabs.com/v1
kind: RedisEnterpriseCluster
metadata:
Expand All @@ -842,13 +852,19 @@ spec:
limits:
cpu: '4'
ephemeral-storage: 10Gi
memory: 4Gi
memory: 8Gi
requests:
cpu: '4'
ephemeral-storage: 1Gi
memory: 4Gi
memory: 8Gi
bootstrapperImageSpec:
repository: registry.connect.redhat.com/redislabs/redis-enterprise-operator
clusterCredentialSecretName: rec
# for testing, we only run 1 node instanc
nodes: 1
# we disable pod anti affinity, so redis pod can run on same host
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution: []
persistentSpec:
enabled: true
storageClassName: local-volume
Expand All @@ -859,6 +875,11 @@ spec:
podStartingPolicy:
enabled: false
startingThresholdSeconds: 540
redisEnterpriseServicesRiggerImageSpec:
repository: registry.connect.redhat.com/redislabs/services-manager
redisEnterpriseImageSpec:
imagePullPolicy: IfNotPresent
repository: registry.connect.redhat.com/redislabs/redis-enterprise
uiServiceType: ClusterIP
clusterCredentialSecretType: kubernetes
servicesRiggerSpec:
Expand All @@ -868,9 +889,9 @@ spec:
apiService:
type: ClusterIP
EOF
oc create --save-config -n llm-demo -f ${BASE_DIR}/tmp/redis-cluster.yaml
oc create --save-config -n llm-demo -f ${BASE_DIR}/data/install/redis-cluster.yaml

# oc delete -n llm-demo -f ${BASE_DIR}/tmp/redis-cluster.yaml
# oc delete -n llm-demo -f ${BASE_DIR}/data/install/redis-cluster.yaml

# before create database, we need to import module
# https://docs.redis.com/latest/stack/install/add-module-to-cluster/
Expand All @@ -886,7 +907,7 @@ oc get route -n llm-demo

oc get secret rec -n llm-demo -o jsonpath="{.data}" | jq 'map_values(@base64d)'
# {
# "password": "3psvXXqv",
# "password": "PP1BuaXT",
# "username": "[email protected]"
# }

Expand All @@ -899,19 +920,22 @@ oc get secret rec -n llm-demo -o jsonpath="{.data}" | jq 'map_values(@base64d)'

```

get search module
<!-- get search module
- https://app.redislabs.com/#/rlec-downloads
![](imgs/2023-11-08-19-50-21.png)
![](imgs/2023-11-08-19-50-21.png) -->

![](imgs/2023-11-08-18-51-30.png)

![](imgs/2023-11-08-22-06-44.png)
<!-- ![](imgs/2023-11-08-22-06-44.png) -->

![](imgs/2023-11-13-17-35-36.png)

```bash

# create database
cat << EOF > ${BASE_DIR}/tmp/redis-db.yaml
# the memory limit for free redis version is aroung 4GB, it is the cluster memory / 2
cat << EOF > ${BASE_DIR}/data/install/redis-db.yaml
apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
Expand All @@ -920,34 +944,41 @@ spec:
memorySize: 4GB
modulesList:
- name: search
version: 2.4.8
version: 2.8.4
persistence: snapshotEvery12Hour
replication: false
tlsMode: disabled
type: redis
# shardCount: 4
EOF
oc create --save-config -n llm-demo -f ${BASE_DIR}/tmp/redis-db.yaml
oc create --save-config -n llm-demo -f ${BASE_DIR}/data/install/redis-db.yaml

# oc delete -n llm-demo -f ${BASE_DIR}/tmp/redis-db.yaml
# oc delete -n llm-demo -f ${BASE_DIR}/data/install/redis-db.yaml

oc get secret -n llm-demo redb-my-doc -o jsonpath="{.data}" | jq 'map_values(@base64d)'
# {
# "password": "E16IqBBU",
# "port": "16972",
# "password": "ABmKLkR0",
# "port": "13858",
# "service_name": "my-doc-headless",
# "service_names": "my-doc, my-doc-headless"
# }

VAR_PWD=`oc get secret -n llm-demo redb-my-doc -o jsonpath="{.data}" | jq 'map_values(@base64d)' | jq -r .password`
VAR_PORT=`oc get secret -n llm-demo redb-my-doc -o jsonpath="{.data}" | jq 'map_values(@base64d)' | jq -r .port`

VAR_REDIS="redis://default:${VAR_PWD}@my-doc-headless.llm-demo.svc.cluster.local:${VAR_PORT}"

echo $VAR_REDIS

```

## try demo for HF

### Simple Chat with memory using HFTGI
## Simple Chat with memory using HFTGI

gradio-hftgi-memory

- https://github.com/rh-aiservices-bu/llm-on-openshift/blob/main/examples/ui/gradio/gradio-hftgi-memory/README.md

```bash

# https://github.com/wangzheng422/llm-on-openshift/tree/wzh/examples/ui/gradio/gradio-hftgi-memory/deployment/wzh
Expand All @@ -962,20 +993,24 @@ oc create -n llm-demo -f ${BASE_DIR}/wzh/

![](imgs/2023-11-08-23-02-20.png)

## Langchain-Redis-Ingest.ipynb

![](imgs/2023-11-08-23-43-00.png)
## Chatbot+HFTGI+Redis

![](imgs/2023-11-08-23-44-59.png)
gradio-hftgi-rag-redis

- https://github.com/rh-aiservices-bu/llm-on-openshift/blob/main/examples/ui/gradio/gradio-hftgi-rag-redis/README.md

```bash


```

### Chatbot+HFTGI+Redis

gradio-hftgi-rag-redis
### Langchain-Redis-Ingest.ipynb

![](imgs/2023-11-08-23-43-00.png)

![](imgs/2023-11-08-23-44-59.png)

```bash

Expand Down
194 changes: 194 additions & 0 deletions redhat/ocp4/4.13/4.13.single.node.upi.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,177 @@ oc adm policy add-cluster-role-to-user cluster-admin admin

oc adm policy add-role-to-user admin user01 -n llm-demo

```

# setup local persistent volume

```bash

# create some static host path to use
# go to worker-01-demo
# 01,02,03,04,05,06,07,08,09,10
for i in $(seq -w 1 20); do
mkdir -p "/var/wzh-local-pv/static/$i"
done
mkdir -p /var/wzh-local-pv/dynamic
chcon -Rt container_file_t /var/wzh-local-pv/

# on helper
cat << EOF > ${BASE_DIR}/data/install/local-sc.yaml
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-volume
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
EOF
oc create --save-config -f ${BASE_DIR}/data/install/local-sc.yaml

cat << EOF > ${BASE_DIR}/data/install/local-pv.yaml
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv-01
spec:
capacity:
storage: 4500Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-volume
local:
path: /var/wzh-local-pv/static/01
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- worker-01-demo
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-pvc-demo
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 4500Gi
storageClassName: local-volume
EOF
oc create --save-config -n llm-demo -f ${BASE_DIR}/data/install/local-pv.yaml

# oc delete -n llm-demo -f ${BASE_DIR}/data/install/local-pv.yaml

# for all diretory, create them
var_i=0
for var_i in $(seq -w 1 20); do
oc create --save-config -n llm-demo -f - << EOF
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv-${var_i}
labels:
local-dir: local-dir-${var_i}
spec:
capacity:
storage: 4500Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-volume
local:
path: /var/wzh-local-pv/static/${var_i}
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- worker-01-demo
EOF
done

for var_i in $(seq -w 1 10); do
oc create --save-config -n llm-demo -f - << EOF
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-pvc-${var_i}
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 4500Gi
storageClassName: local-volume
selector:
matchLabels:
local-dir: local-dir-${var_i}
EOF

done

# then delete

var_i=0
for var_i in $(seq -w 1 10); do
oc delete -n llm-demo -f - << EOF
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-pvc-${var_i}
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 4500Gi
storageClassName: local-volume
EOF
done

var_i=0
for var_i in $(seq -w 1 10); do
oc delete -n llm-demo -f - << EOF
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv-${var_i}
spec:
capacity:
storage: 4500Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-volume
local:
path: /var/wzh-local-pv/static/${var_i}
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- worker-01-demo
EOF
done


```

# setup hostpath provisioner
Expand Down Expand Up @@ -775,4 +946,27 @@ oc create --save-config -f ${BASE_DIR}/data/install/hostpath-storage-class.yaml

```

# setup registry

- https://docs.openshift.com/container-platform/4.13/registry/configuring_registry_storage/configuring-registry-storage-baremetal.html#registry-change-management-state_configuring-registry-storage-baremetal


```bash

cat << EOF > ${BASE_DIR}/data/install/registry.yaml
spec:
managementState: Managed
replicas: 1
storage:
pvc:
claim:
EOF
oc patch config.imageregistry.operator.openshift.io/cluster \
--type=merge \
--patch-file=${BASE_DIR}/data/install/registry.yaml

oc get config.imageregistry.operator.openshift.io/cluster -o json | jq .spec

```

# end
Binary file added redhat/ocp4/4.13/imgs/2023-11-13-17-35-36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b3b3e6d

Please sign in to comment.