Skip to content

Commit

Permalink
Merge branch 'main' into cohere
Browse files Browse the repository at this point in the history
  • Loading branch information
XinyuYe-Intel committed Oct 12, 2024
2 parents e6915ed + ff8ff43 commit 8c720f6
Show file tree
Hide file tree
Showing 121 changed files with 8,007 additions and 1,755 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/slow_tests_gaudi2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: (Gaudi2) Non-regression tests
on:
workflow_dispatch:
schedule:
- cron: '0 23 * * 3,6' # every Wednesday and Saturday at 1am CET (midnight winter time)
- cron: '0 23 * * *' # every Wednesday and Saturday at 1am CET (midnight winter time)

concurrency:
group: ${{ github.workflow }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
--net=host \
--ipc=host \
vault.habana.ai/gaudi-docker/1.17.0/ubuntu22.04/habanalabs/pytorch-installer-2.3.1:latest \
pip install huggingface_hub && huggingface-cli login --token ${{ secrets.TEXT_GENERATION_CI_HUB_TOKEN }} && /bin/bash tests/ci/slow_tests_deepspeed.sh
/bin/bash tests/ci/slow_tests_deepspeed.sh ${{ secrets.TEXT_GENERATION_CI_HUB_TOKEN }}
fsdp:
name: Test FSDP models
if: ${{ !cancelled() && (success() || failure()) }}
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fast_tests:
# Run unit and integration tests related to Diffusers
fast_tests_diffusers:
python -m pip install .[tests]
python -m pip install -r examples/stable-diffusion/requirements.txt
python -m pytest tests/test_diffusers.py

# Run single-card non-regression tests on image classification models
Expand Down Expand Up @@ -94,12 +95,13 @@ slow_tests_deepspeed: test_installs
python -m pytest tests/test_examples.py -v -s -k "deepspeed"

slow_tests_diffusers: test_installs
python -m pytest tests/test_diffusers.py -v -s -k "test_no_"
python -m pip install -r examples/stable-diffusion/requirements.txt
python -m pytest tests/test_diffusers.py -v -s -k "test_textual_inversion"
python -m pip install peft==0.7.0
python -m pytest tests/test_diffusers.py -v -s -k "test_train_text_to_image_"
python -m pytest tests/test_diffusers.py -v -s -k "test_train_controlnet"
python -m pytest tests/test_diffusers.py -v -s -k "test_deterministic_image_generation"
python -m pytest tests/test_diffusers.py -v -s -k "test_no_"

# Run text-generation non-regression tests
slow_tests_text_generation_example: test_installs
Expand All @@ -119,8 +121,8 @@ slow_tests_fsdp: test_installs
python -m pytest tests/test_fsdp_examples.py -v -s --token $(TOKEN)

slow_tests_trl: test_installs
python -m pip install trl==0.8.6
python -m pip install peft==0.7.0
python -m pip install trl==0.9.6
python -m pip install peft==0.12.0
python -m pytest tests/test_trl.py -v -s -k "test_calculate_loss"

slow_tests_object_segmentation: test_installs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ The following model architectures, tasks and device distributions have been vali
| Mixtral | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Persimmon | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Qwen2 | <div style="text-align:left"><li>Single card</li></div> | <div style="text-align:left"><li>Single card</li></div> | <li>[language modeling](https://github.com/huggingface/optimum-habana/tree/main/examples/language-modeling)</li><li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Qwen2-MoE | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Gemma | :heavy_check_mark: | <div style="text-align:left"><li>Single card</li></div> | <li>[language modeling](https://github.com/huggingface/optimum-habana/tree/main/examples/language-modeling)</li><li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Cohere | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| T5 / Flan T5 | :heavy_check_mark: | :heavy_check_mark: | <li>[summarization](https://github.com/huggingface/optimum-habana/tree/main/examples/summarization)</li><li>[translation](https://github.com/huggingface/optimum-habana/tree/main/examples/translation)</li><li>[question answering](https://github.com/huggingface/optimum-habana/tree/main/examples/question-answering#fine-tuning-t5-on-squad20)</li> |
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ In the tables below, ✅ means single-card, multi-card and DeepSpeed have all be
| Mixtral | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Gemma || <div style="text-align:left"><li>Single card</li></div> | <li>[language modeling](https://github.com/huggingface/optimum-habana/tree/main/examples/language-modeling)</li><li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Qwen2 | <div style="text-align:left"><li>Single card</li></div> | <div style="text-align:left"><li>Single card</li></div> | <li>[language modeling](https://github.com/huggingface/optimum-habana/tree/main/examples/language-modeling)</li><li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Qwen2-MoE | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Persimmon | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| Cohere | | <div style="text-align:left"><li>Single card</li></div> | <li>[text generation](https://github.com/huggingface/optimum-habana/tree/main/examples/text-generation)</li> |
| T5 / Flan T5 ||| <li>[summarization](https://github.com/huggingface/optimum-habana/tree/main/examples/summarization)</li><li>[translation](https://github.com/huggingface/optimum-habana/tree/main/examples/translation)</li><li>[question answering](https://github.com/huggingface/optimum-habana/tree/main/examples/question-answering#fine-tuning-t5-on-squad20)</li> |
Expand Down
2 changes: 1 addition & 1 deletion examples/audio-classification/run_audio_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.14.0", "To fix: pip install -r examples/pytorch/audio-classification/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/contrastive-image-text/run_bridgetower.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/contrastive-image-text/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/contrastive-image-text/run_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/contrastive-image-text/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/image-classification/run_image_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=2.14.0", "To fix: pip install -r examples/pytorch/image-classification/requirements.txt")
Expand Down
4 changes: 3 additions & 1 deletion examples/image-to-text/run_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,15 @@ def main():
)
generate_kwargs = {
"lazy_mode": True,
"use_cache": args.use_kv_cache,
"hpu_graphs": args.use_hpu_graphs,
"max_new_tokens": args.max_new_tokens,
"ignore_eos": args.ignore_eos,
"use_flash_attention": args.use_flash_attention,
"flash_attention_recompute": args.flash_attention_recompute,
}
if args.use_kv_cache:
generate_kwargs["use_cache"] = args.use_kv_cache

if args.use_hpu_graphs:
from habana_frameworks.torch.hpu import wrap_in_hpu_graph

Expand Down
2 changes: 1 addition & 1 deletion examples/language-modeling/run_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=2.14.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/language-modeling/run_mlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=2.14.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/language-modeling/run_multitask_prompt_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risk.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/language-modeling/run_prompt_tuning_clm.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/language-modeling/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/question-answering/run_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
Expand Down
2 changes: 1 addition & 1 deletion examples/question-answering/run_seq2seq_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/question-answering/requirements.txt")
Expand Down
24 changes: 24 additions & 0 deletions examples/sentence-transformers-training/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Examples for Sentence Transformers

We provide 3 examples to show how to use Sentence Transformers with HPU devices.

- **[training_stsbenchmark.py](https://github.com/huggingface/optimum-habana/tree/main/examples/sentence-transformers-training/sts)** - This example shows how to create a Sentence Transformers model from scratch by using a pre-trained transformer model (e.g. [`distilbert-base-uncased`](https://huggingface.co/distilbert/distilbert-base-uncased)) together with a pooling layer.

- **[training_nli.py](https://github.com/huggingface/optimum-habana/tree/main/examples/sentence-transformers-training/nli)** - This example provides two sentences (a premise and a hypothesis), and the task of Natural Language Inference (NLI) is to determine whether the premise entails the hypothesis, contradicts it, or if they are neutral. Commonly the NLI dataset in [SNLI](https://huggingface.co/datasets/stanfordnlp/snli) and [MultiNLI](https://huggingface.co/datasets/nyu-mll/multi_nli) are used.

- **[training_paraphrases.py](https://github.com/huggingface/optimum-habana/tree/main/examples/sentence-transformers-training/paraphrases)** - This example loads various datasets from Sentence Transformers. We construct batches by sampling examples from the respective dataset.

### Tested Examples/Models and Configurations

The following table contains examples supported and configurations we have validated on Gaudi2.

| Examples | General | e5-mistral-7b-instruct | BF16 | Single Card | Multi-Cards |
|-----------------------------|-----------|------------|------|-------------|-------------|
| training_nli.py ||||||
| training_stsbenchmark.py ||||||
| training_paraphrases.py || | || |

Notice:
1. In the table, the column 'General' refers to general models like mpnet, MiniLM.
2. When e5-mistral-7b-instruct model is enabled for the test, single card will use LoRA + gradient checkpointing and multi-card will use DeepSpeed ZeRO-2/ZeRO-3 to reduce the memory requirement.
3. For the detailed instructions on how to run each example, you can refer to the README file located in each example folder.
2 changes: 1 addition & 1 deletion examples/speech-recognition/run_speech_recognition_ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def check_optimum_habana_min_version(*a, **b):
logger = logging.getLogger(__name__)

# Will error if the minimal version of Transformers and Optimum Habana are not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def check_optimum_habana_min_version(*a, **b):


# Will error if the minimal version of Transformers is not installed. Remove at your own risks.
check_min_version("4.43.0")
check_min_version("4.45.0")
check_optimum_habana_min_version("1.14.0.dev0")

require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt")
Expand Down
Loading

0 comments on commit 8c720f6

Please sign in to comment.