-
Notifications
You must be signed in to change notification settings - Fork 18
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
Merge test_postgres to main #371
Changes from 53 commits
2422bb7
2a5325f
f9fcd2f
c14446d
4d379a6
13fa070
d237ad2
6e930f8
f0adf0e
f076b4f
c7aebb5
5d78942
71702fb
691834b
49a573c
d2487de
7ea6fe5
51e79b8
9a69782
1f7c0fd
ed8d138
9ba23ae
be0bd9e
72bc167
93265df
fcfc058
1a7dc39
7b9c76e
f5d0d3d
4fbddc6
c92b98d
09226c6
9ca714a
c82c8a6
9c31e12
499bd74
d3aae38
41bc09a
3ba3e11
be33e2f
7034213
7f38ec7
20e9324
d2d938f
c409448
c1ef721
62c9137
bdeeade
d054fa6
620e24b
b04f592
c2da768
5a6e48b
d0e74ea
0a876f8
a86194d
5d1b1ac
378b9f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
--- | ||
title: Deploy an AI model on Azure Kubernetes Service (AKS) with the AI toolchain operator (preview) | ||
description: Learn how to enable the AI toolchain operator add-on on Azure Kubernetes Service (AKS) to simplify OSS AI model management and deployment. | ||
ms.topic: article | ||
ms.custom: azure-kubernetes-service, devx-track-azurecli | ||
ms.date: 02/28/2024 | ||
author: schaffererin | ||
ms.author: schaffererin | ||
|
||
--- | ||
|
||
## Quickstart: Create a Linux virtual machine with the Azure CLI on Azure | ||
|
||
**Applies to:** :heavy_check_mark: Linux VMs | ||
|
||
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://go.microsoft.com/fwlink/?linkid=2262692) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove the button since it is pertaining to the old doc |
||
|
||
This quickstart shows you how to use the Azure CLI to deploy a Linux virtual machine (VM) in Azure. The Azure CLI is used to create and manage Azure resources via either the command line or scripts. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. description change needed since this is a description of an older doc |
||
|
||
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. | ||
|
||
## Deploy an AI model on Azure Kubernetes Service (AKS) with the AI toolchain operator (preview) | ||
|
||
The AI toolchain operator (KAITO) is a managed add-on for AKS that simplifies the experience of running OSS AI models on your AKS clusters. The AI toolchain operator automatically provisions the necessary GPU nodes and sets up the associated inference server as an endpoint server to your AI models. Using this add-on reduces your onboarding time and enables you to focus on AI model usage and development rather than infrastructure setup. | ||
|
||
This article shows you how to enable the AI toolchain operator add-on and deploy an AI model on AKS. | ||
|
||
[!INCLUDE [preview features callout](~/reusable-content/ce-skilling/azure/includes/aks/includes/preview/preview-callout.md)] | ||
|
||
## Before you begin | ||
|
||
* This article assumes a basic understanding of Kubernetes concepts. For more information, see [Kubernetes core concepts for AKS](./concepts-clusters-workloads.md). | ||
* For ***all hosted model inference images*** and recommended infrastructure setup, see the [KAITO GitHub repository](https://github.com/Azure/kaito). | ||
* The AI toolchain operator add-on currently supports KAITO version **v0.1.0**, please make a note of this in considering your choice of model from the KAITO model repository. | ||
|
||
## Prerequisites | ||
|
||
* If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. | ||
* If you have multiple Azure subscriptions, make sure you select the correct subscription in which the resources will be created and charged using the [az account set](https://learn.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az-account-set) command. | ||
|
||
> [!NOTE] | ||
> The subscription you use must have GPU VM quota. | ||
|
||
* Azure CLI version 2.47.0 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli). | ||
* The Kubernetes command-line client, kubectl, installed and configured. For more information, see [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/). | ||
* [Install the Azure CLI AKS preview extension](#install-the-azure-cli-preview-extension). | ||
* [Register the AI toolchain operator add-on feature flag](#register-the-ai-toolchain-operator-add-on-feature-flag). | ||
|
||
## Set up resource group | ||
|
||
Set up a resource group with a random ID. Create an Azure resource group using the [az group create](https://learn.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az-group-create) command. | ||
|
||
```bash | ||
export RANDOM_ID="$(openssl rand -hex 3)" | ||
export AZURE_RESOURCE_GROUP="myKaitoResourceGroup$RANDOM_ID" | ||
export REGION="centralus" | ||
export CLUSTER_NAME="myClusterName$RANDOM_ID" | ||
export SUBSCRIPTION_ID="0c8875c7-e423-4caa-827a-1f0350bd8dd3" | ||
|
||
az group create \ | ||
--name $AZURE_RESOURCE_GROUP \ | ||
--location $REGION \ | ||
``` | ||
|
||
## Install the Azure CLI preview extension | ||
|
||
Install the Azure CLI preview extension using the [az extension add](https://learn.microsoft.com/en-us/cli/azure/extension?view=azure-cli-latest#az-extension-add) command. Then update the extension to make sure you have the latest version using the [az extension update](https://learn.microsoft.com/en-us/cli/azure/extension?view=azure-cli-latest#az-extension-update) command. | ||
|
||
```bash | ||
az extension add --name aks-preview | ||
az extension update --name aks-preview | ||
``` | ||
|
||
## Register the AI toolchain operator add-on feature flag | ||
|
||
Register the AIToolchainOperatorPreview feature flag using the az feature register command. | ||
It takes a few minutes for the registration to complete. | ||
|
||
```bash | ||
az feature register --namespace "Microsoft.ContainerService" --name "AIToolchainOperatorPreview" | ||
``` | ||
|
||
## Verify the AI toolchain operator add-on registration | ||
|
||
Verify the registration using the [az feature show](https://learn.microsoft.com/en-us/cli/azure/feature?view=azure-cli-latest#az-feature-show) command. | ||
|
||
```bash | ||
while true; do | ||
status=$(az feature show --namespace "Microsoft.ContainerService" --name "AIToolchainOperatorPreview" --query "properties.state" -o tsv) | ||
if [ "$status" == "Registered" ]; then | ||
break | ||
else | ||
sleep 15 | ||
fi | ||
done | ||
``` | ||
|
||
## Create an AKS cluster with the AI toolchain operator add-on enabled | ||
|
||
Create an AKS cluster with the AI toolchain operator add-on enabled using the [az aks create](https://learn.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-create) command with the `--enable-ai-toolchain-operator` and `--enable-oidc-issuer` flags. | ||
|
||
```bash | ||
az aks create --location ${REGION} \ | ||
--resource-group ${AZURE_RESOURCE_GROUP} \ | ||
--name ${CLUSTER_NAME} \ | ||
--enable-oidc-issuer \ | ||
--node-os-upgrade-channel SecurityPatch \ | ||
--auto-upgrade-channel stable \ | ||
--enable-ai-toolchain-operator \ | ||
--generate-ssh-keys \ | ||
--k8s-support-plan KubernetesOfficial | ||
``` | ||
|
||
## Connect to your cluster | ||
|
||
Configure `kubectl` to connect to your cluster using the [az aks get-credentials](https://learn.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az-aks-get-credentials) command. | ||
|
||
```bash | ||
az aks get-credentials --resource-group ${AZURE_RESOURCE_GROUP} --name ${CLUSTER_NAME} | ||
``` | ||
|
||
## Create role assignment for the service principal | ||
|
||
```bash | ||
export MC_RESOURCE_GROUP=$(az aks show --resource-group ${AZURE_RESOURCE_GROUP} \ | ||
--name ${CLUSTER_NAME} \ | ||
--query nodeResourceGroup \ | ||
-o tsv) | ||
|
||
export KAITO_IDENTITY_NAME="ai-toolchain-operator-${CLUSTER_NAME}" | ||
|
||
export AKS_OIDC_ISSUER=$(az aks show --resource-group "${AZURE_RESOURCE_GROUP}" \ | ||
--name "${CLUSTER_NAME}" \ | ||
--query "oidcIssuerProfile.issuerUrl" \ | ||
-o tsv) | ||
|
||
export PRINCIPAL_ID=$(az identity show --name "ai-toolchain-operator-${CLUSTER_NAME}" \ | ||
--resource-group "${MC_RESOURCE_GROUP}" \ | ||
--query 'principalId' \ | ||
-o tsv) | ||
|
||
az role assignment create --role "Contributor" \ | ||
--assignee "${PRINCIPAL_ID}" \ | ||
--scope "/subscriptions/${SUBSCRIPTION_ID}/resourcegroups/${AZURE_RESOURCE_GROUP}" | ||
``` | ||
|
||
## Establish a federated identity credential | ||
|
||
Create the federated identity credential between the managed identity, AKS OIDC issuer, and subject using the [az identity federated-credential create](https://learn.microsoft.com/en-us/cli/azure/identity/federated-credential?view=azure-cli-latest) command. | ||
|
||
```bash | ||
az identity federated-credential create --name "kaito-federated-identity" \ | ||
--identity-name "${KAITO_IDENTITY_NAME}" \ | ||
-g "${MC_RESOURCE_GROUP}" \ | ||
--issuer "${AKS_OIDC_ISSUER}" \ | ||
--subject system:serviceaccount:"kube-system:kaito-gpu-provisioner" \ | ||
--audience api://AzureADTokenExchange | ||
``` | ||
|
||
## Verify that your deployment is running | ||
|
||
Restart the KAITO GPU provisioner deployment on your pods using the `kubectl rollout restart` command: | ||
|
||
```bash | ||
kubectl rollout restart deployment/kaito-gpu-provisioner -n kube-system | ||
``` | ||
|
||
## Deploy a default hosted AI model | ||
|
||
Deploy the Falcon 7B-instruct model from the KAITO model repository using the `kubectl apply` command. | ||
|
||
```bash | ||
kubectl apply -f https://raw.githubusercontent.com/Azure/kaito/main/examples/inference/kaito_workspace_falcon_7b-instruct.yaml | ||
``` | ||
|
||
## Ask a question | ||
|
||
Verify deployment done: `kubectl get workspace workspace-falcon-7b-instruct -w`. | ||
Store IP: `export SERVICE_IP=$(kubectl get svc workspace-falcon-7b-instruct -o jsonpath='{.spec.clusterIP}')`. | ||
Ask question: `kubectl run -it --rm --restart=Never curl --image=curlimages/curl -- curl -X POST http://$SERVICE_IP/chat -H "accept: application/json" -H "Content-Type: application/json" -d "{\"prompt\":\"YOUR QUESTION HERE\"}"` | ||
|
||
```bash | ||
echo "See last step for details on how to ask questions to the model." | ||
``` | ||
|
||
## Next steps | ||
|
||
For more inference model options, see the [KAITO GitHub repository](https://github.com/Azure/kaito). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
title: 'Quickstart: Deploy a Postgres vector database' | ||
description: Setup a Postgres vector database and openai resources to run a RAG-LLM model. | ||
ms.topic: quickstart | ||
ms.date: 09/06/2024 | ||
author: aamini7 | ||
ms.author: ariaamini | ||
ms.custom: innovation-engine, linux-related-content | ||
--- | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add an intro/some description around the scenario |
||
## Set up resource group | ||
|
||
Set up a resource group with a random ID. | ||
|
||
```bash | ||
export RANDOM_ID="$(openssl rand -hex 3)" | ||
export RG_NAME="myPostgresResourceGroup$RANDOM_ID" | ||
export REGION="centralus" | ||
|
||
az group create \ | ||
--name $RG_NAME \ | ||
--location $REGION \ | ||
``` | ||
|
||
## Create OpenAI resources | ||
|
||
Create the openai resource | ||
|
||
```bash | ||
export OPEN_AI_SERVICE_NAME="openai-service-$RANDOM_ID" | ||
export EMBEDDING_MODEL="text-embedding-ada-002" | ||
export CHAT_MODEL="gpt-4-turbo-2024-04-09" | ||
|
||
az cognitiveservices account create \ | ||
--name $OPEN_AI_SERVICE_NAME \ | ||
--resource-group $RG_NAME \ | ||
--location westus \ | ||
--kind OpenAI \ | ||
--sku s0 \ | ||
``` | ||
|
||
## Create OpenAI deployments | ||
|
||
```bash | ||
export EMBEDDING_MODEL="text-embedding-ada-002" | ||
export CHAT_MODEL="gpt-4" | ||
|
||
az cognitiveservices account deployment create \ | ||
--name $OPEN_AI_SERVICE_NAME \ | ||
--resource-group $RG_NAME \ | ||
--deployment-name $EMBEDDING_MODEL \ | ||
--model-name $EMBEDDING_MODEL \ | ||
--model-version "2" \ | ||
--model-format OpenAI \ | ||
--sku-capacity "1" \ | ||
--sku-name "Standard" | ||
|
||
az cognitiveservices account deployment create \ | ||
--name $OPEN_AI_SERVICE_NAME \ | ||
--resource-group $RG_NAME \ | ||
--deployment-name $CHAT_MODEL \ | ||
--model-name $CHAT_MODEL \ | ||
--model-version "turbo-2024-04-09" \ | ||
--model-format OpenAI \ | ||
--sku-capacity "1" \ | ||
--sku-name "Standard" | ||
``` | ||
|
||
## Create Database | ||
|
||
Create an Azure postgres database. | ||
|
||
```bash | ||
export POSTGRES_SERVER_NAME="mydb$RANDOM_ID" | ||
export PGHOST="${POSTGRES_SERVER_NAME}.postgres.database.azure.com" | ||
export PGUSER="dbadmin$RANDOM_ID" | ||
export PGPORT=5432 | ||
export PGDATABASE="azure-ai-demo" | ||
export PGPASSWORD="$(openssl rand -base64 32)" | ||
|
||
az postgres flexible-server create \ | ||
--admin-password $PGPASSWORD \ | ||
--admin-user $PGUSER \ | ||
--location $REGION \ | ||
--name $POSTGRES_SERVER_NAME \ | ||
--database-name $PGDATABASE \ | ||
--resource-group $RG_NAME \ | ||
--sku-name Standard_B2s \ | ||
--storage-auto-grow Disabled \ | ||
--storage-size 32 \ | ||
--tier Burstable \ | ||
--version 16 \ | ||
--yes -o JSON \ | ||
--public-access 0.0.0.0 | ||
``` | ||
|
||
## Enable postgres vector extension | ||
|
||
Set up the vector extension for postgres to allow storing vectors/embeddings. | ||
|
||
```bash | ||
az postgres flexible-server parameter set \ | ||
--resource-group $RG_NAME \ | ||
--server-name $POSTGRES_SERVER_NAME \ | ||
--name azure.extensions --value vector | ||
|
||
psql -c "CREATE EXTENSION IF NOT EXISTS vector;" | ||
|
||
psql \ | ||
-c "CREATE TABLE embeddings(id int PRIMARY KEY, data text, embedding vector(1536));" \ | ||
-c "CREATE INDEX ON embeddings USING hnsw (embedding vector_ip_ops);" | ||
``` | ||
|
||
## Populate with data from knowledge file | ||
|
||
The chat bot uses a local file called "knowledge.txt" as the sample document to generate embeddings for | ||
and to store those embeddings in the newly created postgres database. Then any questions you ask will | ||
be augmented with context from the "knowledge.txt" after searching the document for the most relevant | ||
pieces of context using the embeddings. The "knowledge.txt" is about a fictional material called Zytonium. | ||
You can view the full knowledge.txt and the code for the chatbot by looking in the "scenarios/PostgresRagLlmDemo" directory. | ||
|
||
```bash | ||
export ENDPOINT=$(az cognitiveservices account show --name $OPEN_AI_SERVICE_NAME --resource-group $RG_NAME | jq -r .properties.endpoint) | ||
export API_KEY=$(az cognitiveservices account keys list --name $OPEN_AI_SERVICE_NAME --resource-group $RG_NAME | jq -r .key1) | ||
|
||
cd ~/scenarios/PostgresRagLlmDemo | ||
pip install -r requirements.txt | ||
python chat.py --populate --api-key $API_KEY --endpoint $ENDPOINT --pguser $PGUSER --phhost $PGHOST --pgpassword $PGPASSWORD --pgdatabase $PGDATABASE | ||
``` | ||
|
||
## Run Chat bot | ||
|
||
This final step prints out the command you can copy/paste into the terminal to run the chatbot. `cd ~/scenarios/PostgresRagLlmDemo && python chat.py --api-key $API_KEY --endpoint $ENDPOINT --pguser $PGUSER --phhost $PGHOST --pgpassword $PGPASSWORD --pgdatabase $PGDATABASE` | ||
|
||
```bash | ||
echo " | ||
To run the chatbot, see the last step for more info. | ||
" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title needs to be updated