Training and fine-tuning
Labs 28–33: single-GPU fine-tuning, Kubeflow Trainer, LoRA and QLoRA, Ray, Kueue and checkpointing.
Most organisations fine-tune rather than train from scratch. These labs cover the tools, queueing GPU jobs fairly, and not losing a day of work to a killed pod.
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 28: Single-GPU fine-tuning in a workbench
- Lab 29: Distributed training with Kubeflow Trainer
- Lab 30: LoRA and QLoRA fine-tuning
- Lab 31: Ray and CodeFlare: Ray Train and Ray Tune
- Lab 32: Kueue: quotas, fair share, preemption and borrowing
- Lab 33: Checkpointing to ONTAP and ODF
Lab 28: Single-GPU fine-tuning in a workbench
Goal: Fine-tune a small model on one GPU and save the result for serving.
Prerequisites
- Labs 3 and 10
- A small dataset in S3
Environment notes
Use the full-GPU profile; time-sliced GPUs share memory and may run out mid-job.
Steps
- Load a small model and dataset in a PyTorch workbench.
- Fine-tune for a short run with Hugging Face
Trainer. - Watch GPU memory and utilisation.
- Save the model to S3.
- Serve it (Lab 14) and compare with the base model.
Verification
- Training loss falls and the saved model loads.
- The tuned model answers your test prompts better than the base.
Lab 29: Distributed training with Kubeflow Trainer
Goal: Run a training job across several GPUs, on one server and then across servers, and see the network cost.
Prerequisites
- Lab 28
- Training operator enabled
Environment notes
L40S cards are PCIe without NVLink. Without RDMA, traffic between servers goes over the pod network, so scaling across servers is limited.
Steps
- Run a
TrainJoborPyTorchJobwith one worker and one GPU. - Run it with two GPUs on the same node.
- Run it with GPUs on two nodes.
- Record time per step for each.
- Explain the result in terms of the interconnect.
Verification
- All three runs complete.
- You have time-per-step numbers showing where scaling stops paying.
Lab 30: LoRA and QLoRA fine-tuning
Goal: Fine-tune an 8B model on a single L40S with parameter-efficient methods.
Prerequisites
- Lab 28
Environment notes
Full fine-tuning of 8B needs more than 48 GB; LoRA usually fits, and QLoRA fits with room to spare.
Steps
- Prepare an instruction dataset.
- Run LoRA with the Training Hub or an InstructLab-style flow.
- Run QLoRA with 4-bit base weights.
- Compare memory, time and quality.
- Merge or serve the adapter.
Verification
- Both runs fit on one GPU.
- The adapted model improves on your evaluation set.
Lab 31: Ray and CodeFlare: Ray Train and Ray Tune
Goal: Use Ray for distributed training and hyperparameter search.
Prerequisites
- Lab 28
- Ray (KubeRay and CodeFlare) enabled
Environment notes
Size the Ray cluster with hardware profiles and queue it with Kueue.
Steps
- Create a
RayClusterfrom a notebook with the CodeFlare SDK. - Run a Ray Train job on two GPUs.
- Run a Ray Tune sweep over learning rate and batch size.
- Read the Ray dashboard.
- Tear the cluster down from the notebook.
Verification
- The sweep finds a best trial.
- Resources are released when the cluster is removed.
Lab 32: Kueue: quotas, fair share, preemption and borrowing
Goal: Share a small pool of GPUs between teams without arguments.
Prerequisites
- Lab 5
- Kueue enabled
Environment notes
With time-slicing on, quotas count shared GPU replicas, not physical cards.
Steps
- Create a
ResourceFlavorfor GPU nodes and aClusterQueuewith a GPU quota per team in a cohort. - Create a
LocalQueuein each team project. - Submit more jobs than fit and watch them queue.
- Let one team borrow unused quota from another.
- Submit a high-priority job and watch preemption.
Verification
- Jobs wait instead of failing when GPUs are busy.
- Borrowing and preemption behave as configured.
Lab 33: Checkpointing to ONTAP and ODF
Goal: Save training state to persistent storage and resume after failure.
Prerequisites
- Lab 28 or 29
- RWX storage (Lab 9)
Environment notes
Checkpoints for large models are big; check volume size and write speed.
Steps
- Write checkpoints every N steps to a persistent volume.
- Delete the training pod mid-run.
- Resume from the latest checkpoint.
- Snapshot the checkpoint volume.
- Compare write times on NAS and Ceph storage.
Verification
- The job resumes from the last checkpoint, not from step zero.
- No more than N steps of work are lost.