Llama 3.1 Fine-Tuning With Ray on OpenShift AI: A Practical Plan
Fine-tuning Llama 3.1 with Ray on OpenShift AI requires more than a model name and a GPU request. Choose an approved model, verify the versioned accelerator and runtime combination, prepare separate training and evaluation data, then run a small reviewed job before scaling. Ray must coordinate the actual training workload; starting a Ray connection alone does not distribute an ordinary trainer.
Topic: MLOps & AI Infrastructure in AI & Data · Tutorial
Also covers: Generative AI & LLMs, OpenShift
Learning path: Generative AI & AI Infrastructure, lesson 11 of 14
Quick answer: Fine-tuning Llama 3.1 with Ray on OpenShift AI requires more than a model name and a GPU request. Choose an approved model, verify the versioned accelerator and runtime combination, prepare separate training and evaluation data, then run a small reviewed job before scaling. Ray must coordinate the actual training workload; starting a Ray connection alone does not distribute an ordinary trainer. The offline example below checks invented data only and does not claim to launch a cluster or train a model.
Key takeaways
- Define an evaluation task before allocating a training cluster.
- Check the exact runtime support status and accelerator operator matrix.
- Keep model access and licence checks in the project record.
- Inspect train/evaluation overlap before running a job.
- Validate one small job and checkpoint recovery before scaling.
Table of Contents
- What should you decide before choosing a Llama training recipe?
- Which OpenShift AI and Ray versions should you use?
- How can you catch a simple data problem without a GPU?
- How should you connect GPU requests to Ray training workers?
- What should the first small training job prove?
- How should you judge checkpoints and model quality?
- What belongs in the final experiment handover?
- References
What should you decide before choosing a Llama training recipe?
Start with a task that a reviewer can judge. In this fictional example, a team wants an assistant to answer questions about an approved training lab. It prepares expected answers for account-reset and lab-ownership questions, plus questions the assistant should decline because the supplied material does not answer them. No employee records enter the experiment.
Check the exact Meta Llama 3.1 8B Instruct model card and Meta Llama 3.1 licence before downloading or distributing a model. Record the identifier and terms you reviewed. A family name does not establish access, licensing permission, context requirements or memory fit. Keep an unchanged base-model comparison so the team can later decide whether fine-tuning improved the task it actually cares about.
Which OpenShift AI and Ray versions should you use?
Treat a published example as versioned evidence. The Red Hat Llama fine-tuning example, September 2024 is a dated workflow with stated prerequisites. The later Red Hat Ray LoRA workflow, August 2026 demonstrates a different model and runtime arrangement. It does not establish that replacing its model identifier with Llama produces a validated recipe.
Consult the OpenShift AI tested and supported configurations for the selected release. The reviewed matrix distinguishes Ray images that are tested and verified from official support; accelerator compatibility also depends on the relevant operator and vendor matrix. Record these boundaries explicitly rather than describing every listed image as fully supported.
| Decision | Record before execution | Reason |
|---|---|---|
| Platform | OpenShift and OpenShift AI release | Controllers and APIs vary |
| Accelerator | Device, driver and operator versions | Hardware visibility alone is insufficient |
| Runtime | Image digest and Ray/framework versions | Current documentation may describe a newer API |
| Training recipe | Repository revision and configuration | Examples can change after review |
| Model and data | Identifiers, terms and approved dataset revision | Results need traceable inputs |
Have the platform owner confirm the combination. Pin the reviewed image and recipe revision for the experiment, then plan updates separately. This prevents a moving tag from silently changing the environment between the smoke job and the larger run.
How can you catch a simple data problem without a GPU?
The lab team first checks whether the same prompt appears in both splits after case and whitespace normalisation. This small program uses the Python json module and an invented teaching schema. A real recipe may expect different fields, chat templates or file layouts; convert only after reading that recipe's contract.
import json
# Invented examples in a teaching schema, not a trainer input contract.
training = json.loads('[{"prompt":"Reset my lab password",'
'"answer":"Use the approved training reset page."}]')
evaluation = json.loads('[{"prompt":" reset MY lab password ",'
'"answer":"Use the approved training reset page."},'
'{"prompt":"Who owns the lab?",'
'"answer":"The training administrator."}]')
def normalise(text):
return " ".join(text.casefold().split())
def prompts(rows):
values = set()
for row in rows:
for field in ("prompt", "answer"):
if not isinstance(row.get(field), str) or not row[field].strip():
raise ValueError(f"Missing nonempty string: {field}")
values.add(normalise(row["prompt"]))
return values
overlap = prompts(training) & prompts(evaluation)
print(f"overlapping normalised prompts: {len(overlap)}")
for prompt in sorted(overlap):
print(prompt)The checked output reports one overlapping prompt: reset my lab password. Move or replace the duplicated example according to the evaluation plan, then rerun the check. Do not use the shown data as a real training set. This is a deliberately small fixture that exposes one kind of leakage and validates nonempty string fields.
The exact displayed Python program was executed locally. It does not detect paraphrases, prove label quality, apply a tokenizer or validate a trainer's input format. Add human review for contradictory answers, private data and unsupported instructions before creating the approved dataset revision.
How should you connect GPU requests to Ray training workers?
Review the Kubernetes GPU scheduling with the cluster administrator to understand how the installed device plugin exposes accelerator resources. A GPU present on a node is not automatically available to every pod. Quotas, scheduling constraints and the configured resource request can prevent a worker from starting.
The Ray Train ScalingConfig reference describes worker and resource configuration, while the Ray Train distributed PyTorch workflow explains a distributed PyTorch training workflow. Match those APIs to the installed runtime. Simply connecting to Ray and calling an ordinary trainer does not establish coordinated distributed execution. Avoid publishing an unreviewed manifest that mixes API versions or assumes the cluster already has the required controllers.
What should the first small training job prove?
Use the approved recipe's smallest useful run to check dataset loading, model access, accelerator allocation and checkpoint writing. Keep secrets in the platform's approved mechanism rather than embedding access tokens in a notebook, image or article. Give the job access only to the storage and services it needs.
Watch worker startup and failure messages before increasing the allocation. Confirm that the intended number of workers actually participates and that the loss and progress records belong to this run. If a worker remains pending, investigate scheduling first. If workers start but the model fails to load, inspect access, runtime compatibility and memory demand. These failures call for different evidence.
| Observed problem | First evidence to collect | Avoid concluding |
|---|---|---|
| Worker stays pending | Scheduling events and resource availability | The dataset is corrupt |
| Model access is rejected | Approved identity and model access status | More GPUs will fix it |
| Allocation fails during loading | Runtime logs and memory demand | A smaller batch always solves it |
| Checkpoint cannot be read | Storage location, permissions and saved artefacts | A completed progress bar proves recoverability |
How should you judge checkpoints and model quality?
Retain the run configuration and test whether the saved artefact can be loaded through the intended workflow. Record whether the output is an adapter, another checkpoint format or a packaged model, because the next serving step must understand it. A storage path appearing in logs is not a successful recovery test.
Compare the base and adapted model using the same held-out questions and review criteria. In the fictional lab case, a reviewer checks answer correctness, unsupported claims and appropriate refusals. Keep examples of regressions as well as improvements. Training loss alone cannot show whether the assistant became more useful, and a tiny held-out set cannot establish broad reliability.
What belongs in the final experiment handover?
Provide the model identifier, reviewed terms, dataset revision, recipe commit, image digest, resource allocation, logs, checkpoint location and evaluation notes. Include the known limits and the person responsible for approving a serving trial. Keep the evaluation data separate from examples used to tune the recipe repeatedly.
No OpenShift cluster, GPU workload or Llama training run was executed for this article. The verified code is the offline data check, and the larger workflow is a planning and review sequence. Before a real run, confirm current platform support and the chosen recipe with the responsible administrators, then capture evidence from that environment.
Related reading: local inference GPU troubleshooting; AMD stack compatibility; pipeline planning.
References
- Meta Llama 3.1 8B Instruct model card
- Meta Llama 3.1 licence
- Red Hat Llama fine-tuning example, September 2024
- Red Hat Ray LoRA workflow, August 2026
- OpenShift AI tested and supported configurations
- Python json module
- Kubernetes GPU scheduling
- Ray Train ScalingConfig reference
- Ray Train distributed PyTorch workflow
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0