Model serving with KServe

Labs 12–20: OpenVINO and vLLM, NVIDIA NIM, custom runtimes, OCI modelcars, secure endpoints, autoscaling, rollouts, llm-d and benchmarking.

Updated CompTech Team

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

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

  1. Deploy a small classic model on OpenVINO Model Server.
  2. Deploy a small LLM on the vLLM runtime with one GPU.
  3. Call both endpoints with curl and from a notebook.
  4. Measure latency for single requests and throughput with ten parallel requests.
  5. Read the pod logs to see model load time.

Verification

  • Both InferenceService objects are Ready.
  • 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

  1. Enable NVIDIA NIM in Applications and confirm the key is validated.
  2. Deploy a Llama 3.1 8B NIM with one GPU.
  3. Deploy an embedding NIM.
  4. Call the OpenAI-compatible chat and embeddings endpoints.
  5. Compare answers and tokens per second with a 1B model.

Verification

  • Both NIMs answer through /v1/chat/completions and /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

  1. Create a serving runtime from the vLLM template with your own image tag and arguments.
  2. Serve a Granite, Mistral or Qwen model.
  3. Change --max-model-len and --gpu-memory-utilization and observe memory use.
  4. Serve an AWQ, GPTQ or FP8 version of the same model.
  5. 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

  1. Build an image that contains only the model files under /models.
  2. Push it to the registry.
  3. Deploy an InferenceService with an oci:// storage URI.
  4. Restart the pod and note image caching on the node.
  5. 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

  1. Deploy a model with token authentication and no external route.
  2. Create a service account for a client and grant it access to the model.
  3. Call the endpoint with and without a token.
  4. Add an external route and an AuthPolicy.
  5. Add a RateLimitPolicy and exceed it.

Verification

  • Unauthenticated calls get 401; calls over the limit get 429.
  • 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

  1. Set minimum and maximum replicas on the model.
  2. Create a KEDA ScaledObject on a request metric such as queue depth or requests per second.
  3. Generate load and watch replicas rise.
  4. Stop the load and watch scale-down.
  5. 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

  1. Deploy version A of a model.
  2. Deploy version B beside it.
  3. Send 10% of traffic to B by weight.
  4. Route a test header to B for A/B testing.
  5. 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

  1. Deploy an LLMInferenceService with a single replica.
  2. Add a second decode replica and enable cache-aware routing.
  3. Enable separate prefill and decode pods.
  4. Send repeated prompts with a shared prefix and watch cache hits in metrics.
  5. 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

  1. Run GuideLLM against a model on a full GPU with a sweep of concurrency levels.
  2. Record time to first token, inter-token latency and throughput.
  3. Repeat on a time-sliced GPU with a second load on the same card.
  4. Run vllm bench serve for a second opinion.
  5. 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.