Model serving with KServe
Labs 12–20: OpenVINO and vLLM, NVIDIA NIM, custom runtimes, OCI modelcars, secure endpoints, autoscaling, rollouts, llm-d and benchmarking.
OpenShift AI 3.x serves models with KServe. These labs go from the first endpoint to production concerns: security, scaling, rollout and measuring what you get from each GPU.
Every lab assumes the environment described in the series overview. Commands and names are examples: replace them with your own.
Labs in this section
- Lab 12: OpenVINO Model Server and vLLM, CPU against GPU
- Lab 13: NVIDIA NIM: an 8B LLM and an embedding NIM
- Lab 14: Custom vLLM runtime with Hugging Face models and quantization
- Lab 15: Modelcar: serving a model from an OCI image
- Lab 16: Secure endpoints: authentication, routes and rate limits
- Lab 17: Autoscaling with HPA and KEDA, including scale to zero
- Lab 18: Canary and A/B rollouts between model versions
- Lab 19: Distributed inference with llm-d
- Lab 20: Benchmarking with GuideLLM and vLLM bench
Lab 12: OpenVINO Model Server and vLLM, CPU against GPU
Goal: Serve the same kind of model on CPU and GPU runtimes and compare latency and throughput.
Prerequisites
- Labs 3 and 8
- A model in an S3 connection
Environment notes
OpenVINO Model Server runs well on CPU; vLLM needs a GPU for useful LLM speed. Use the full-GPU hardware profile for vLLM.
Steps
- Deploy a small classic model on OpenVINO Model Server.
- Deploy a small LLM on the vLLM runtime with one GPU.
- Call both endpoints with
curland from a notebook. - Measure latency for single requests and throughput with ten parallel requests.
- Read the pod logs to see model load time.
Verification
- Both
InferenceServiceobjects areReady. - You have a short CPU vs GPU comparison with numbers.
Lab 13: NVIDIA NIM: an 8B LLM and an embedding NIM
Goal: Serve NVIDIA NIM microservices from OpenShift AI and compare them with a smaller model.
Prerequisites
- Lab 12
- NIM enabled in OpenShift AI with a valid NGC API key stored as a secret
Environment notes
An 8B model fits on one 48 GB L40S. NIM images may not start under FIPS mode; see Lab 56 for how to scope that exception. Model caches are large, so give them a fast persistent volume.
Steps
- Enable NVIDIA NIM in Applications and confirm the key is validated.
- Deploy a Llama 3.1 8B NIM with one GPU.
- Deploy an embedding NIM.
- Call the OpenAI-compatible chat and embeddings endpoints.
- Compare answers and tokens per second with a 1B model.
Verification
- Both NIMs answer through
/v1/chat/completionsand/v1/embeddings. - The cache volume is reused when a pod restarts.
Lab 14: Custom vLLM runtime with Hugging Face models and quantization
Goal: Run a model that is not in the catalog and tune vLLM for the card you have.
Prerequisites
- Lab 12
- Access to Hugging Face, or the model mirrored to S3 or OCI
Environment notes
Store the Hugging Face token as a secret (Lab 59). Context length and KV cache size are limited by GPU memory: tune them rather than accepting defaults.
Steps
- Create a serving runtime from the vLLM template with your own image tag and arguments.
- Serve a Granite, Mistral or Qwen model.
- Change
--max-model-lenand--gpu-memory-utilizationand observe memory use. - Serve an AWQ, GPTQ or FP8 version of the same model.
- Compare quality on a few prompts and tokens per second.
Verification
- The custom runtime appears in the dashboard and serves the model.
- You can explain the trade-off between context length, quantization and concurrency.
Lab 15: Modelcar: serving a model from an OCI image
Goal: Package model weights as an OCI image so the registry, not S3, distributes models.
Prerequisites
- Lab 12
- A container registry
Environment notes
Modelcars reuse image pull, mirroring and signing. In a disconnected site they mirror like any other image.
Steps
- Build an image that contains only the model files under
/models. - Push it to the registry.
- Deploy an
InferenceServicewith anoci://storage URI. - Restart the pod and note image caching on the node.
- Compare start time with loading the same model from S3.
Verification
- The model serves from the OCI image.
- You have measured start times for both methods.
Lab 16: Secure endpoints: authentication, routes and rate limits
Goal: Expose a model safely: token authentication, internal-only by default, and rate limiting.
Prerequisites
- Lab 12
- Connectivity Link (Authorino and Limitador) installed
Environment notes
Keep endpoints internal unless a consumer outside the cluster needs them. Use service accounts and short-lived tokens for clients.
Steps
- Deploy a model with token authentication and no external route.
- Create a service account for a client and grant it access to the model.
- Call the endpoint with and without a token.
- Add an external route and an
AuthPolicy. - Add a
RateLimitPolicyand exceed it.
Verification
- Unauthenticated calls get
401; calls over the limit get429. - The endpoint is unreachable from outside when no route exists.
Lab 17: Autoscaling with HPA and KEDA, including scale to zero
Goal: Scale model servers on load and release GPUs when idle.
Prerequisites
- Lab 12
- Custom Metrics Autoscaler (KEDA) installed
Environment notes
GPU pods are slow to start because weights load first, so set scale-down delays carefully. Scale to zero saves a GPU at the cost of a cold start.
Steps
- Set minimum and maximum replicas on the model.
- Create a KEDA
ScaledObjecton a request metric such as queue depth or requests per second. - Generate load and watch replicas rise.
- Stop the load and watch scale-down.
- Enable scale to zero and measure the cold start.
Verification
- Replicas follow load within your target.
- You have a measured cold-start time to share with application teams.
Lab 18: Canary and A/B rollouts between model versions
Goal: Move traffic to a new model gradually and compare versions on real requests.
Prerequisites
- Labs 12 and 16
Environment notes
Service Mesh 3 or the Gateway API can split traffic by weight or header.
Steps
- Deploy version A of a model.
- Deploy version B beside it.
- Send 10% of traffic to B by weight.
- Route a test header to B for A/B testing.
- Promote B to 100%, then roll back to A.
Verification
- Request logs show the expected split.
- Rollback restores 100% to A without downtime.
Lab 19: Distributed inference with llm-d
Goal: Use llm-d for prefill/decode disaggregation and KV-cache-aware routing.
Prerequisites
- Lab 12
- llm-d enabled in the DataScienceCluster
- At least two GPUs
Environment notes
Prefill and decode split helps most with long prompts and many users. Without RDMA between servers, keep prefill and decode pods on one server.
Steps
- Deploy an
LLMInferenceServicewith a single replica. - Add a second decode replica and enable cache-aware routing.
- Enable separate prefill and decode pods.
- Send repeated prompts with a shared prefix and watch cache hits in metrics.
- Compare latency with the plain vLLM deployment.
Verification
- Requests with a shared prefix go to the same pod.
- You can show when llm-d helps and when it doesn't.
Lab 20: Benchmarking with GuideLLM and vLLM bench
Goal: Measure tokens per second and latency honestly, and compare a full GPU with a time-sliced share.
Prerequisites
- Labs 3 and 12
Environment notes
Benchmark one variable at a time. Time-sliced GPUs share compute and memory, so results depend on what else is running.
Steps
- Run GuideLLM against a model on a full GPU with a sweep of concurrency levels.
- Record time to first token, inter-token latency and throughput.
- Repeat on a time-sliced GPU with a second load on the same card.
- Run
vllm bench servefor a second opinion. - Plot the results and write a sizing note.
Verification
- You have a table of throughput and latency by concurrency for both setups.
- The note states how many concurrent users one L40S can serve at your latency target.