Skip to content

fix(training-ref-arch): repair the model fine-tuning pipeline and upgrade its dependencies - #617

Open
karajendran wants to merge 2 commits into
mainfrom
fix/training-ref-arch-mft-pipeline
Open

karajendran wants to merge 2 commits into
mainfrom
fix/training-ref-arch-mft-pipeline

Conversation

@karajendran

Copy link
Copy Markdown
Collaborator

Summary

The model fine-tuning pipeline of the training reference architecture no longer ran: its data preparation step called Llama 3.1 on Vertex AI (MaaS), which is no longer available.

  • Data preparation: questions and answers are generated from templates with Ray Data, on the Ray cluster of the data processing step (new modules/python/src/datapreparation, with unit tests). No model API is needed, and the dataset is reproducible. Six questions for each product.
  • Data processing: writes the full cleaned catalog again. Since Distributed Data Processing updated with Ray Data & Ray Job #498 the RAG selection ran on every batch and removed columns that the data preparation reads.
  • Fine-tuning: PyTorch 2.15, transformers 5.23, trl 1.18 and peft 0.22. The script keeps a copy of the adapter in every checkpoint and loads it when the job resumes, because peft 0.20.0 and later don't restore it under FSDP (set_peft_model_state_dict silently loads nothing into an FSDP-wrapped model since 0.20.0 (Trainer resume loses the adapter) huggingface/peft#4223). It stops with an error instead of saving a model without the fine-tuning. The A100 job uses a batch size of 8 and the "job-1" values.
  • Evaluation: vLLM v0.34.0. The job sends the questions concurrently (about 5 minutes for 3,350 questions instead of 95) and also reports exact answers and product details accuracy, because the previous accuracy is 100% for questions that name the product.
  • Versions: Ray 2.60.0, MLflow 3.18.0, Python 3.12.16 base images. No pinned package of the pipeline has a known advisory.

Validation

  • Ran the four steps as documented on GKE Standard with 2 x A100: 20,000 products, 12,931 training prompts, fine-tuning in 138 minutes, 3,009 of 3,350 exact answers (89.8%) and 98.2% product details accuracy.
  • Restart check: a fine-tuning job that runs again on its checkpoints saves the same model, and a resumed job continues at the loss where it stopped.
  • 67 unit tests with 92% coverage; black, isort, prettier, cspell and terraform fmt pass.
  • Not run: the H100 and L4 jobs. The test used unsloth/gemma-2-9b-it, an ungated copy of google/gemma-2-9b-it.

…rade its dependencies

The data preparation step of the model fine-tuning pipeline called Llama 3.1 on
Vertex AI (MaaS), which is no longer available, and the data processing step no
longer wrote the columns that the data preparation reads.

- Data preparation: generate the questions and answers from templates with Ray
  Data, on the Ray cluster of the data processing step
  (modules/python/src/datapreparation). The step needs no model API, and
  preparing the data again gives the same data set. Six questions for each
  product.
- Data processing: write the full cleaned catalog again.
- Fine-tuning: move to PyTorch 2.15, transformers 5.23, trl 1.18 and peft 0.22,
  and adapt the script to their APIs. Save a copy of the adapter with every
  checkpoint and load it when the job resumes, because peft 0.20.0 and later
  don't restore the adapter of a model that is distributed with FSDP. Stop with
  an error instead of saving a model without the fine-tuning. Use the AdamW
  optimizer of PyTorch, the bitsandbytes optimizer fails at the first
  checkpoint. The job for the NVIDIA A100 accelerators uses a batch size of 8
  and the "job-1" values of the README.
- Model evaluation: vLLM v0.34.0. Send the questions concurrently, and compare
  the predictions with the expected answers (exact answers, product details
  accuracy).
- Ray 2.60.0, MLflow 3.18.0, Python 3.12.16 base images. The MLflow tracking
  server keeps a copy of its database before it upgrades the schema.
- Terraform: the data preparation step no longer needs access to Vertex AI.
- Guides: steps, results and durations of a run on two NVIDIA A100 accelerators.
…guides

- Fine-tuning guide: the command that deletes the model folder is an optional
  step before the job is created. It was listed after the job had succeeded,
  where it deletes the fine-tuned model.
- Guides: up to six questions for each product; the evaluation uses the
  validation and the test data sets together; the L4 inference deployment was
  not run; the results of the base job are described with their numbers; the
  screenshots of the previous data preparation job are removed and its diagram
  is marked as such; the earlier results keep the "Built with Meta Llama 3.1"
  notice.
- Comments: the workaround in fine_tune.py names the peft issue and when it
  can be removed; the packages that the Ray workers install are marked as
  temporary; the Dockerfile says which torch build is installed; the test of
  the category split says which pandas version it guards.

No change to executable code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant