An AI/ML platform is the shared ground that lets many teams build, ship, and run models without each rebuilding the same plumbing: data from the lakehouse, a feature store, managed training on shared GPUs, experiment tracking and a model registry, serving for online and batch inference, an AI gateway in front of hosted and self-hosted language models, evaluation and guardrails, monitoring, and governance with cost per team. This lesson follows one team from "we have an idea" to a model and an LLM feature in production, and shows the two ways platforms fail: every team running its own GPU stack, and LLM calls going straight to providers with keys in code.
Difficulty: Master · Know this first: Lesson 161, Lesson 148
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up hours of one team's work from idea to production. It is a worked example, not a measurement. The training and gateway hops are where teams either reuse the platform or pay for not having one.
Pick how training, serving, and LLM access are provided for 10 teams. The readouts show time to production, GPU utilisation, and what a leaked key costs.
Three questions. No score is saved anywhere — this is just you against the material.
AI/ML platforms grow in four levels: using the platform, building its pieces, operating it as shared infrastructure, and running it as a governed product.
At the basic level you can take a model from data to production with the platform's paved road.
Where it breaks: working around the platform "just this once" with a key or a private GPU VM.
Try it: Basic
Your service needs an LLM. How should it call one?
Now do it: Route one model call through a gateway.
At the intermediate level you build platform components.
Try it: Intermediate
One team's large training job blocks everyone else's. What fixes it?
Now do it: Set quotas for two teams in a test cluster.
At the advanced level the platform has SLOs and capacity plans of its own.
Try it: Advanced
Which number tells you the shared GPU pool is too small?
Now do it: Plot queue wait for a week.
At the master level the platform is a product with users, a roadmap, and governance built in.
Trade-off: a central platform can become a bottleneck; templates and self-service keep teams fast while control stays central.
Try it: Master
Confidential data must not be sent to external model providers. Where is that enforced?
Now do it: Write the routing rule for one data class.
The layers and the common choices on each cloud (and open source). Platforms mix them; what matters is that each layer is shared, owned, and measured.
A Kueue setup that gives two teams a guaranteed share of a GPU pool, borrowing from each other when idle (check the Kueue documentation for your version):
apiVersion: kueue.x-k8s.io/v1beta1
kind: ClusterQueue
metadata: {name: forecasting}
spec:
cohort: gpu-pool # queues in a cohort can borrow unused quota
namespaceSelector: {}
resourceGroups:
- coveredResources: ["nvidia.com/gpu"]
flavors:
- name: a100
resources:
- {name: "nvidia.com/gpu", nominalQuota: 8, borrowingLimit: 8}
---
apiVersion: kueue.x-k8s.io/v1beta1
kind: LocalQueue
metadata: {name: training, namespace: forecasting}
spec: {clusterQueue: forecasting}
This is a composite of a failure pattern that keeps repeating; the details are illustrative. One shared key, many services.
Provider keys exist only in the AI gateway, services authenticate to it with workload identity, each team has a budget and rate limit, prompts are logged with redaction, and secret scanning blocks provider keys in repositories.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: A practice cluster for the Kubernetes steps: Docker, kind, and kubectl, then kind create cluster. The program needs only Python 3.
Type each one, read what it prints, and compare it with the note above it.
See which nodes offer GPUs and how many (none on a kind cluster, which is the point of the next steps).
kubectl get nodes -o custom-columns=NAME:.metadata.name,GPUS:.status.allocatable.nvidia\.com/gpu
Install Kueue, the job queueing controller, into the practice cluster.
Changes a real system: Installing a cluster-wide controller changes how jobs are scheduled: practise on kind, roll out to shared clusters through your platform's change process.
kubectl apply --server-side -f https://github.com/kubernetes-sigs/kueue/releases/download/v0.10.1/manifests.yaml kubectl -n kueue-system rollout status deploy/kueue-controller-manager --timeout=180s
List the queue objects Kueue added: these are how teams get quotas on a shared pool.
kubectl api-resources --api-group=kueue.x-k8s.io
ai_gateway.pyThis program is a small AI gateway: services call it with their identity, it holds the provider keys, applies each team's monthly budget, routes confidential data only to the self-hosted model, and records every call for audit. Then it compares GPU utilisation for ten per-team GPU stacks with one shared, queued pool. Save it as ai_gateway.py, then run it.
# ai_gateway.py
BUDGET = {"forecasting": 2000.0, "support-bot": 500.0}
PRICE_PER_1K = {"hosted-large": 0.010, "hosted-small": 0.001, "self-hosted": 0.0004}
ALLOWED = {"public": ["hosted-large", "hosted-small", "self-hosted"], "confidential": ["self-hosted"]}
spent = {t: 0.0 for t in BUDGET}
audit = []
def call(team, model, tokens, data_class):
if team not in BUDGET:
return "401 unknown caller"
if model not in ALLOWED[data_class]:
model = ALLOWED[data_class][0] # reroute instead of leaking confidential data
note = " (rerouted for " + data_class + " data)"
else:
note = ""
cost = tokens / 1000 * PRICE_PER_1K[model]
if spent[team] + cost > BUDGET[team]:
audit.append((team, model, tokens, "DENIED: budget"))
return f"429 {team} over its monthly budget"
spent[team] += cost
audit.append((team, model, tokens, "ok"))
return f"200 {model}{note}, {cost:.2f} USD"
print(call("forecasting", "hosted-large", 120_000, "public"))
print(call("forecasting", "hosted-large", 80_000, "confidential"))
print(call("support-bot", "hosted-large", 60_000_000, "public"))
print(call("leaked-key-user", "hosted-large", 1_000_000, "public"))
print("spend:", {t: round(s, 2) for t, s in spent.items()}, "| audit entries:", len(audit))
print()
HOURS_USED = [3, 2, 4, 1, 6, 2, 3, 5, 2, 4] # hours a day each team runs an 8-GPU job
gpu_hours = sum(h * 8 for h in HOURS_USED)
per_team = gpu_hours / (len(HOURS_USED) * 8 * 24)
pool_gpus = 16 # one shared pool sized for the combined, queued demand
pooled = gpu_hours / (pool_gpus * 24)
print(f"10 stacks of 8 GPUs: {len(HOURS_USED) * 8} GPUs at {per_team:.0%} utilisation")
print(f"one queued pool: {pool_gpus} GPUs at {pooled:.0%} utilisation for the same work")
Run it, and you should see this output:
$ python3 ai_gateway.py
200 hosted-large, 1.20 USD
200 self-hosted (rerouted for confidential data), 0.03 USD
429 support-bot over its monthly budget
401 unknown caller
spend: {'forecasting': 1.23, 'support-bot': 0.0} | audit entries: 3
10 stacks of 8 GPUs: 80 GPUs at 13% utilisation
one queued pool: 16 GPUs at 67% utilisation for the same work
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/ai-ml-platform-architecture && cd ~/labs/ai-ml-platform-architecture) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "AI/ML Platform Architecture: From Data to Models and LLMs in Production", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'See which nodes offer GPUs and how many (none on a kind cluster, which is the point of the next steps).'
'Install Kueue, the job queueing controller, into the practice cluster.'
'List the queue objects Kueue added: these are how teams get quotas on a shared pool.'
)
step_1() {
kubectl get nodes -o custom-columns=NAME:.metadata.name,GPUS:.status.allocatable.nvidia\.com/gpu
}
step_2() {
kubectl apply --server-side -f https://github.com/kubernetes-sigs/kueue/releases/download/v0.10.1/manifests.yaml
kubectl -n kueue-system rollout status deploy/kueue-controller-manager --timeout=180s
}
step_3() {
kubectl api-resources --api-group=kueue.x-k8s.io
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
Ten teams use ML and language models in ten different ways, with nine GPU clusters and provider keys in many repositories. Design the AI/ML platform and the migration.
Which layers does the platform own, and which stay with teams? How is GPU capacity shared and bought? How do LLM calls flow, and what does the gateway enforce? How are models and prompts evaluated and governed? How do you measure the platform's success? In what order do teams move?
Say 10 teams, 60 GPUs at 18% average utilisation, 40 million LLM tokens a day across two providers, and a self-hosted open model for confidential data.
A lakehouse with catalog grants; a shared feature store; one Kubernetes GPU pool with Kueue quotas per team, Spot for training with checkpoints, reserved capacity for serving; MLflow tracking and registry with gate templates; KServe and vLLM serving templates with SLOs; an AI gateway holding all provider keys with workload identity, budgets, routing (confidential data only to the self-hosted model), redacted logging, and guardrails; evaluation sets in CI; an inventory with risk tiers; monthly cost per team; teams migrate starting with those holding provider keys, then GPU stacks by utilisation.
Centralising slows teams that had freedom and removes duplicated work and unbounded risk; a shared pool needs fair scheduling and clear priorities; the gateway is a critical dependency, so it needs its own SLO and redundancy.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| A GPU stack per team | Hop 3: Training | Breaks | There is no shared training. The team spends six weeks building a GPU node pool, drivers, images, a pipeline tool, and serving, then runs one training job a night. Its GPUs average 14% utilisation; eight other teams have done the same. |
| LLM keys in code | Hop 6: AI gateway | Breaks | There is no gateway. Services call providers directly with a shared key in a configuration file in the repository. The repository is mirrored to a contractor's system and the key leaks. Over a weekend it is used for $38,000 of requests. |
Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.