-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✏️ docs: Add training guide and improve documentation consistency (#110)
* fix inconsistency in documentation and add training documentation * complete the overview page * remove no needed gitignore * remove no needed gitignore
- Loading branch information
1 parent
b105a83
commit 77f8f97
Showing
6 changed files
with
79 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Training on TPU | ||
|
||
Welcome to the 🤗 Optimum-TPU training guide! This section covers how to fine-tune models using Google Cloud TPUs. | ||
|
||
## Currently Supported Models | ||
|
||
The following models have been tested and validated for fine-tuning on TPU v5e: | ||
|
||
- 🦙 LLaMA Family | ||
- LLaMA-2 7B | ||
- LLaMA-3 8B | ||
- 💎 Gemma Family | ||
- Gemma 2B | ||
- Gemma 7B | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
Before starting the training process, ensure you have: | ||
|
||
1. A configured Google Cloud TPU instance (see [Deployment Guide](./deploy)) | ||
2. Optimum-TPU installed with PyTorch/XLA support: | ||
```bash | ||
pip install optimum-tpu -f https://storage.googleapis.com/libtpu-releases/index.html | ||
export PJRT_DEVICE=TPU | ||
``` | ||
|
||
### Example Training Scripts | ||
|
||
We provide several example scripts to help you get started: | ||
|
||
1. Gemma Fine-tuning: | ||
- See our [Gemma fine-tuning notebook](https://github.com/huggingface/optimum-tpu/blob/main/examples/language-modeling/gemma_tuning.ipynb) for a step-by-step guide | ||
|
||
2. LLaMA Fine-tuning: | ||
- Check our [LLaMA fine-tuning script](https://github.com/huggingface/optimum-tpu/blob/main/examples/language-modeling/llama_tuning.md) for detailed instructions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
<!--- | ||
Copyright 2023 The HuggingFace Team. All rights reserved. | ||
# Overview | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
Welcome to the 🤗 Optimum-TPU tutorials! Here you'll find comprehensive examples and guides to help you leverage Google Cloud TPUs effectively with Hugging Face models. | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
## Available Examples | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
### Text Generation | ||
Learn how to perform efficient inference for text generation tasks: | ||
|
||
# Overview | ||
- **Basic Generation Script** ([examples/text-generation/generation.py](https://github.com/huggingface/optimum-tpu/blob/main/examples/text-generation/generation.py)) | ||
- Demonstrates text generation using models like Gemma and Mistral | ||
- Features greedy sampling implementation | ||
- Shows how to use static caching for improved performance | ||
- Includes performance measurement and timing analysis | ||
- Supports custom model loading and configuration | ||
|
||
### Language Model Fine-tuning | ||
Explore how to fine-tune language models on TPU infrastructure: | ||
|
||
1. **Interactive Gemma Tutorial** ([examples/language-modeling/gemma_tuning.ipynb](https://github.com/huggingface/optimum-tpu/blob/main/examples/language-modeling/gemma_tuning.ipynb)) | ||
- Complete notebook showing Gemma fine-tuning process | ||
- Covers environment setup and TPU configuration | ||
- Demonstrates FSDPv2 integration for efficient model sharding | ||
- Includes dataset preparation and PEFT/LoRA implementation | ||
- Provides step-by-step training workflow | ||
|
||
2. **LLaMA Fine-tuning Guide** ([examples/language-modeling/llama_tuning.md](https://github.com/huggingface/optimum-tpu/blob/main/examples/language-modeling/llama_tuning.md)) | ||
- Detailed guide for fine-tuning LLaMA-2 and LLaMA-3 models | ||
- Explains SPMD and FSDP concepts | ||
- Shows how to implement efficient data parallel training | ||
- Includes practical code examples and prerequisites | ||
|
||
## Additional Resources | ||
|
||
- Visit the [Optimum-TPU GitHub repository](https://github.com/huggingface/optimum-tpu) for more details | ||
- Explore the [Google Cloud TPU documentation](https://cloud.google.com/tpu/docs) for deeper understanding of TPU architecture | ||
|
||
Welcome to the 🤗 Optimum-TPU tutorials! | ||
For the latest updates and to contribute to these examples, visit our [GitHub repository](https://github.com/huggingface/optimum-tpu). |