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.

Jan 22, 2025 - 12:07
Updated: 
102.1k

MLOps & AI Infrastructure in AI & Data · Tutorial

Generative AI & LLMs, OpenShift

Generative AI & AI Infrastructure, lesson 11 of 14

Llama 3.1 Fine-Tuning With Ray on OpenShift AI: A Practical Plan

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?

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.

DecisionRecord before executionReason
PlatformOpenShift and OpenShift AI releaseControllers and APIs vary
AcceleratorDevice, driver and operator versionsHardware visibility alone is insufficient
RuntimeImage digest and Ray/framework versionsCurrent documentation may describe a newer API
Training recipeRepository revision and configurationExamples can change after review
Model and dataIdentifiers, terms and approved dataset revisionResults 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 problemFirst evidence to collectAvoid concluding
Worker stays pendingScheduling events and resource availabilityThe dataset is corrupt
Model access is rejectedApproved identity and model access statusMore GPUs will fix it
Allocation fails during loadingRuntime logs and memory demandA smaller batch always solves it
Checkpoint cannot be readStorage location, permissions and saved artefactsA 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

Frequently Asked Questions

No; the training implementation must use an appropriate distributed workflow and compatible framework integration for the installed runtime and intended worker arrangement.

A different model can require changes to access, tokenisation, configuration and memory planning, so substitution needs review and validation.

The reviewed configuration page distinguishes tested and verified Ray images from official support, so check the wording for your chosen release.

It checks nonempty strings and exact prompt overlap after case and whitespace normalisation, using invented records in a teaching schema.

No; paraphrases, answer contamination and repeated tuning against the same evaluation set require additional methods and careful human review.

Review the official Meta Llama 3.1 licence and applicable access terms instead of assuming a generic open-source licence applies.

Inspect scheduling events, quotas and available resources first, because a pending worker may not have received any accelerator allocation.

Only the displayed offline Python data check was executed; cluster scheduling, model training and checkpoint recovery require separate environment-specific validation.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.