AI workloads and data locality
Separate training from inference
Training adjusts model parameters and can run for hours; inference serves predictions using an existing model. A small bookstore recommendation API might use CPU inference, while a large model may require accelerators. A distributed training run may require all cooperating workers to be schedulable together. Gang scheduling is a group-admission or placement capability that needs a compatible implementation, such as a supported Kubeflow Trainer integration; an ordinary Job with parallelism does not guarantee simultaneous placement. Checkpoint model state, optimizer state and data progress to durable approved storage; verify resume compatibility.
training: bounded run -> checkpoint -> evaluated artifactinference: request -> loaded model -> prediction -> latency/error measurementRequest hardware and verify locality
A device plugin can advertise an extended resource such as nvidia.com/gpu; a matching GPU limit requests that device, with the request defaulting to the same value when omitted. This does not specify GPU memory or guarantee framework compatibility. Verify device type, driver, runtime, memory needs, node labels and taints. DRA is another allocation approach covered in Chapter 54; verify driver and feature support rather than assuming it is interchangeable. A local persistent volume has node affinity; delayed binding with WaitForFirstConsumer helps align volume selection and Pod scheduling. Remote data may add startup delay, bandwidth costs and contention. A node with a free GPU but no accessible dataset is not a suitable candidate.
resources: requests: cpu: "1" memory: 2Gi limits: cpu: "2" memory: 4Gi nvidia.com/gpu: 1Serve a model with bounded demand
Inference may use a Deployment and Service or a specialized serving controller such as KServe. A startup probe can allow initialization time before regular checks begin; readiness should reflect ability to serve the model, not just a listening port. Limit input size, queue length, concurrency, generation length where applicable, retries and request deadlines. Scale on useful demand signals such as queued requests, latency or token processing metrics when supported; CPU usage alone may miss GPU saturation. Autoscaling has startup delays and must respect quota and cost guardrails. Reject or defer excess work deliberately rather than accept an unbounded queue.
Observed sustainable throughput: 20 requests/s per replica (invented)Target demand: 45 requests/sceil(45/20) = 3 replicas; verify tail latency and headroomCalculate a budget before provisioning
For the fictional inference plan, each replica needs one GPU and serves twenty requests per second under a fixed mock workload. Three replicas satisfy a simple 45 requests/s arithmetic gate if three compatible GPUs are available. At an invented 2 USD per GPU-hour, the three replicas cost 18 USD over three hours, before CPU, storage and networking. A compute-only budget of 15 USD fails the gate. If two GPUs are available, do not claim readiness just because the desired replica count is three. For real serving, load-test a fixed model, input distribution and batch settings; review latency percentiles, memory and cold starts.
3 replicas * 1 GPU * 3 hours * 2 USD/GPU-hour = 18 USDcompute budget 15 USD -> HOLD3 GPU capacity and budget 20 USD -> arithmetic gates pass onlyProtect model and data boundaries
Record the model digest, tokenizer or preprocessing version, license, dataset authorization and evaluation evidence. Verify provenance and signatures when the approved workflow supports them; a hash alone proves equality to an expected digest, not that the model is trustworthy. Use narrowly scoped workload identity to retrieve artifacts, not shared keys. Limit retention of prompts and predictions, avoid real customer data in exercises, and verify denied access. Model readiness, numerical quality and privacy are independent gates. No model downloads, GPU allocations or external requests occur in this lab.
Artifact identity verified + data approved + latency tested + owner approvalMissing evidence -> HOLDPractice and next step
Use inference-cases.json and locality-cases.json to calculate replicas and GPU-hours, screen data-access constraints, and decide HOLD or CANDIDATE. Run the offline validator and explain why a candidate still needs a measured serving test. Next: FinOps and Kubernetes cost optimization.
No live inference or distributed training; hypothetical rates only.Further reading
- https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/ — Device plugin GPU requests
- https://trainer.kubeflow.org/en/latest/operator-guides/job-scheduling/overview.html — Distributed training gang scheduling
- https://kubernetes.io/docs/reference/storage/volume-types/ — Local volume affinity
- https://kubernetes.io/docs/concepts/storage/storage-classes/ — Delayed volume binding
- https://kubernetes.io/docs/concepts/workloads/pods/probes/ — Startup and readiness checks
- https://kserve.github.io/website/docs/model-serving/generative-inference/autoscaling — Inference-specific scaling signals
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
AI workloads and data locality — knowledge check
Design a bounded inference workload plan
Does ordinary Job parallelism guarantee gang scheduling?
A local volume is attached to one node. What must placement respect?
At 20 requests/s per replica, how many replicas satisfy 45 requests/s in the simple model?
Three GPUs for three hours at fictional 2 USD/GPU-hour cost how much?
Does a matching artifact digest prove a model is trustworthy?