Ci test tf super slow (#8007)
* Test TF GPU CI * Change cache * Fix missing torch requirement * Fix some model tests Style * LXMERT * MobileBERT * Longformer skip test * XLNet * The rest of the tests * RAG goes OOM in multi gpu setup * YAML test files * Last fixes * Skip doctests * Fill mask tests * Yaml files * Last test fix * Style * Update cache * Change ONNX tests to slow + use tiny model
This commit is contained in:
122
.github/workflows/self-push.yml
vendored
122
.github/workflows/self-push.yml
vendored
@@ -13,7 +13,7 @@ on:
|
|||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run_tests_torch_and_tf_gpu:
|
run_tests_torch_gpu:
|
||||||
runs-on: [self-hosted, single-gpu]
|
runs-on: [self-hosted, single-gpu]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: .env
|
path: .env
|
||||||
key: v1-tests_tf_torch_gpu-${{ hashFiles('setup.py') }}
|
key: v1.1-tests_torch_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
run: |
|
run: |
|
||||||
@@ -46,8 +46,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install torch!=1.6.0
|
pip install .[torch,sklearn,testing,onnxruntime]
|
||||||
pip install .[sklearn,testing,onnxruntime]
|
|
||||||
pip install git+https://github.com/huggingface/datasets
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
|
||||||
- name: Are GPUs recognized by our DL frameworks
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
@@ -58,16 +57,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all non-slow tests on GPU
|
- name: Run all non-slow tests on GPU
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
|
||||||
# TF_GPU_MEMORY_LIMIT: 4096
|
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
|
CUDA_VISIBLE_DEVICES: 0
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
python -m pytest -n 2 --dist=loadfile -s tests
|
python -m pytest -n 2 --dist=loadfile -s ./tests/
|
||||||
|
|
||||||
|
run_tests_tf_gpu:
|
||||||
run_tests_torch_and_tf_multiple_gpu:
|
runs-on: [self-hosted, single-gpu]
|
||||||
runs-on: [self-hosted, multi-gpu]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Python version
|
- name: Python version
|
||||||
@@ -84,7 +81,57 @@ jobs:
|
|||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: .env
|
path: .env
|
||||||
key: v1-tests_tf_torch_multiple_gpu-${{ hashFiles('setup.py') }}
|
key: v1.1-tests_tf_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
|
run: |
|
||||||
|
python -m venv .env
|
||||||
|
source .env/bin/activate
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install .[tf,sklearn,testing,onnxruntime]
|
||||||
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
|
||||||
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('TF GPUs available:', bool(tf.config.list_physical_devices('GPU')))"
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('Number of TF GPUs available:', len(tf.config.list_physical_devices('GPU')))"
|
||||||
|
|
||||||
|
- name: Run all non-slow tests on GPU
|
||||||
|
env:
|
||||||
|
OMP_NUM_THREADS: 1
|
||||||
|
CUDA_VISIBLE_DEVICES: 0
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
python -m pytest -n 2 --dist=loadfile -s ./tests/
|
||||||
|
|
||||||
|
run_tests_torch_multiple_gpu:
|
||||||
|
runs-on: [self-hosted, multi-gpu]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Python version
|
||||||
|
run: |
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Current dir
|
||||||
|
run: pwd
|
||||||
|
- run: nvidia-smi
|
||||||
|
|
||||||
|
- name: Loading cache.
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: cache
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
key: v1.1-tests_torch_multiple_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
run: |
|
run: |
|
||||||
@@ -97,8 +144,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install torch!=1.6.0
|
pip install .[torch,sklearn,testing,onnxruntime]
|
||||||
pip install .[sklearn,testing,onnxruntime]
|
|
||||||
pip install git+https://github.com/huggingface/datasets
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
|
||||||
- name: Are GPUs recognized by our DL frameworks
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
@@ -109,8 +155,54 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all non-slow tests on GPU
|
- name: Run all non-slow tests on GPU
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
OMP_NUM_THREADS: 1
|
||||||
# TF_GPU_MEMORY_LIMIT: 4096
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
python -m pytest -n 2 --dist=loadfile -s ./tests/
|
||||||
|
|
||||||
|
run_tests_tf_multiple_gpu:
|
||||||
|
runs-on: [self-hosted, multi-gpu]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Python version
|
||||||
|
run: |
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Current dir
|
||||||
|
run: pwd
|
||||||
|
- run: nvidia-smi
|
||||||
|
|
||||||
|
- name: Loading cache.
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: cache
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
key: v1.1-tests_tf_multiple_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
|
run: |
|
||||||
|
python -m venv .env
|
||||||
|
source .env/bin/activate
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install .[tf,sklearn,testing,onnxruntime]
|
||||||
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
|
||||||
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('TF GPUs available:', bool(tf.config.list_physical_devices('GPU')))"
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('Number of TF GPUs available:', len(tf.config.list_physical_devices('GPU')))"
|
||||||
|
|
||||||
|
- name: Run all non-slow tests on GPU
|
||||||
|
env:
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
|
|||||||
201
.github/workflows/self-scheduled.yml
vendored
201
.github/workflows/self-scheduled.yml
vendored
@@ -9,7 +9,7 @@ on:
|
|||||||
- cron: "0 0 * * *"
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run_all_tests_torch_and_tf_gpu:
|
run_all_tests_torch_gpu:
|
||||||
runs-on: [self-hosted, single-gpu]
|
runs-on: [self-hosted, single-gpu]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: .env
|
path: .env
|
||||||
key: v1-slow_tests_tf_torch_gpu-${{ hashFiles('setup.py') }}
|
key: v 1.1-slow_tests_torch_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
- name: Python version
|
- name: Python version
|
||||||
run: |
|
run: |
|
||||||
@@ -44,9 +44,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install torch!=1.6.0
|
pip install .[torch,sklearn,testing,onnxruntime]
|
||||||
pip install .[sklearn,testing,onnxruntime]
|
|
||||||
pip install git+https://github.com/huggingface/datasets
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
pip list
|
||||||
|
|
||||||
- name: Are GPUs recognized by our DL frameworks
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
run: |
|
run: |
|
||||||
@@ -56,31 +56,29 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all tests on GPU
|
- name: Run all tests on GPU
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
RUN_SLOW: yes
|
RUN_SLOW: yes
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
python -m pytest -n 1 --dist=loadfile -s --make_reports=tests tests
|
python -m pytest -n 1 --dist=loadfile -s --make_reports=tests_torch tests
|
||||||
|
|
||||||
- name: Failure short reports
|
- name: Failure short reports
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat reports/report_tests_failures_short.txt
|
run: cat reports/report_test_torch_failures_short.txt
|
||||||
|
|
||||||
- name: Run examples tests on GPU
|
- name: Run examples tests on GPU
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
RUN_SLOW: yes
|
RUN_SLOW: yes
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install -r examples/requirements.txt
|
pip install -r examples/requirements.txt
|
||||||
python -m pytest -n 1 --dist=loadfile -s --make_reports=examples examples
|
python -m pytest -n 1 --dist=loadfile -s --make_reports=examples_torch examples
|
||||||
|
|
||||||
- name: Failure short reports
|
- name: Failure short reports
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat reports/report_examples_failures_short.txt
|
run: cat reports/report_examples_torch_failures_short.txt
|
||||||
|
|
||||||
- name: Run all pipeline tests on GPU
|
- name: Run all pipeline tests on GPU
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
@@ -91,21 +89,85 @@ jobs:
|
|||||||
RUN_PIPELINE_TESTS: yes
|
RUN_PIPELINE_TESTS: yes
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
python -m pytest -n 1 --dist=loadfile -s -m is_pipeline_test --make_reports=tests_pipeline tests
|
python -m pytest -n 1 --dist=loadfile -s -m is_pipeline_test --make_reports=tests_torch_pipeline tests
|
||||||
|
|
||||||
- name: Failure short reports
|
- name: Failure short reports
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat reports/report_tests_pipeline_failures_short.txt
|
run: cat reports/report_tests_torch_pipeline_failures_short.txt
|
||||||
|
|
||||||
- name: Test suite reports artifacts
|
- name: Test suite reports artifacts
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: run_all_tests_torch_and_tf_gpu_test_reports
|
name: run_all_tests_torch_gpu_test_reports
|
||||||
path: reports
|
path: reports
|
||||||
|
|
||||||
|
|
||||||
run_all_tests_torch_and_tf_multiple_gpu:
|
run_all_tests_tf_gpu:
|
||||||
|
runs-on: [self-hosted, single-gpu]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Loading cache.
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: cache
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
key: v1.1-slow_tests_tf_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
|
- name: Python version
|
||||||
|
run: |
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Current dir
|
||||||
|
run: pwd
|
||||||
|
- run: nvidia-smi
|
||||||
|
|
||||||
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
python -m venv .env
|
||||||
|
source .env/bin/activate
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install .[tf,sklearn,testing,onnxruntime]
|
||||||
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
pip list
|
||||||
|
|
||||||
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('TF GPUs available:', bool(tf.config.list_physical_devices('GPU')))"
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('Number of TF GPUs available:', len(tf.config.list_physical_devices('GPU')))"
|
||||||
|
|
||||||
|
- name: Run all tests on GPU
|
||||||
|
env:
|
||||||
|
OMP_NUM_THREADS: 1
|
||||||
|
RUN_SLOW: yes
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
python -m pytest -n 1 --dist=loadfile -s --make_reports=tests_tf tests
|
||||||
|
|
||||||
|
- name: Failure short reports
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: cat reports/report_test_tf_failures_short.txt
|
||||||
|
|
||||||
|
- name: Test suite reports artifacts
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: run_all_tests_tf_gpu_test_reports
|
||||||
|
path: reports
|
||||||
|
|
||||||
|
run_all_tests_torch_multiple_gpu:
|
||||||
runs-on: [self-hosted, multi-gpu]
|
runs-on: [self-hosted, multi-gpu]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -115,16 +177,18 @@ jobs:
|
|||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: .env
|
path: .env
|
||||||
key: v1-slow_tests_tf_torch_multi_gpu-${{ hashFiles('setup.py') }}
|
key: v0.1-slow_tests_torch_multi_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
- name: Python version
|
- name: Python version
|
||||||
run: |
|
run: |
|
||||||
which python
|
which python
|
||||||
python --version
|
python --version
|
||||||
pip --version
|
pip --version
|
||||||
|
|
||||||
- name: Current dir
|
- name: Current dir
|
||||||
run: pwd
|
run: pwd
|
||||||
- run: nvidia-smi
|
- run: nvidia-smi
|
||||||
|
|
||||||
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
@@ -133,13 +197,14 @@ jobs:
|
|||||||
which python
|
which python
|
||||||
python --version
|
python --version
|
||||||
pip --version
|
pip --version
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install torch!=1.6.0
|
pip install .[torch,sklearn,testing,onnxruntime]
|
||||||
pip install .[sklearn,testing,onnxruntime]
|
|
||||||
pip install git+https://github.com/huggingface/datasets
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
pip list
|
||||||
|
|
||||||
- name: Are GPUs recognized by our DL frameworks
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
run: |
|
run: |
|
||||||
@@ -149,22 +214,104 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all tests on GPU
|
- name: Run all tests on GPU
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
RUN_SLOW: yes
|
RUN_SLOW: yes
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
python -m pytest -n 1 --dist=loadfile -s ./tests/ --durations=50
|
python -m pytest -n 1 --dist=loadfile -s --make_reports=tests_torch tests
|
||||||
|
|
||||||
|
- name: Failure short reports
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: cat reports/report_test_torch_failures_short.txt
|
||||||
|
|
||||||
- name: Run examples tests on GPU
|
- name: Run examples tests on GPU
|
||||||
|
if: ${{ always() }}
|
||||||
env:
|
env:
|
||||||
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
|
||||||
OMP_NUM_THREADS: 1
|
OMP_NUM_THREADS: 1
|
||||||
RUN_SLOW: yes
|
RUN_SLOW: yes
|
||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip install -r examples/requirements.txt
|
pip install -r examples/requirements.txt
|
||||||
python -m pytest -n 1 --dist=loadfile -s examples --durations=50
|
python -m pytest -n 1 --dist=loadfile -s --make_reports=examples_torch examples
|
||||||
|
|
||||||
|
- name: Failure short reports
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: cat reports/report_examples_torch_failures_short.txt
|
||||||
|
|
||||||
|
- name: Run all pipeline tests on GPU
|
||||||
|
if: ${{ always() }}
|
||||||
|
env:
|
||||||
|
TF_FORCE_GPU_ALLOW_GROWTH: "true"
|
||||||
|
OMP_NUM_THREADS: 1
|
||||||
|
RUN_SLOW: yes
|
||||||
|
RUN_PIPELINE_TESTS: yes
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
python -m pytest -n 1 --dist=loadfile -s -m is_pipeline_test --make_reports=tests_torch_pipeline tests
|
||||||
|
|
||||||
|
- name: Failure short reports
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: cat reports/report_tests_torch_pipeline_failures_short.txt
|
||||||
|
|
||||||
|
- name: Test suite reports artifacts
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: run_all_tests_torch_multi_gpu_test_reports
|
||||||
|
path: reports
|
||||||
|
|
||||||
|
run_all_tests_tf_multiple_gpu:
|
||||||
|
runs-on: [self-hosted, multi-gpu]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Loading cache.
|
||||||
|
uses: actions/cache@v2
|
||||||
|
id: cache
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
key: v0.1-slow_tests_tf_multi_gpu-${{ hashFiles('setup.py') }}
|
||||||
|
|
||||||
|
- name: Python version
|
||||||
|
run: |
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Current dir
|
||||||
|
run: pwd
|
||||||
|
- run: nvidia-smi
|
||||||
|
|
||||||
|
- name: Create new python env (on self-hosted runners we have to handle isolation ourselves)
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
python -m venv .env
|
||||||
|
source .env/bin/activate
|
||||||
|
which python
|
||||||
|
python --version
|
||||||
|
pip --version
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install .[tf,sklearn,testing,onnxruntime]
|
||||||
|
pip install git+https://github.com/huggingface/datasets
|
||||||
|
pip list
|
||||||
|
|
||||||
|
- name: Are GPUs recognized by our DL frameworks
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('TF GPUs available:', bool(tf.config.list_physical_devices('GPU')))"
|
||||||
|
TF_CPP_MIN_LOG_LEVEL=3 python -c "import tensorflow as tf; print('Number of TF GPUs available:', len(tf.config.list_physical_devices('GPU')))"
|
||||||
|
|
||||||
|
- name: Run all tests on GPU
|
||||||
|
env:
|
||||||
|
OMP_NUM_THREADS: 1
|
||||||
|
RUN_SLOW: yes
|
||||||
|
run: |
|
||||||
|
source .env/bin/activate
|
||||||
|
python -m pytest -n 1 --dist=loadfile -s ./tests/ --durations=0
|
||||||
|
|
||||||
- name: Run all pipeline tests on GPU
|
- name: Run all pipeline tests on GPU
|
||||||
env:
|
env:
|
||||||
@@ -175,3 +322,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
python -m pytest -n 1 --dist=loadfile -s ./tests/ -m is_pipeline_test --durations=50
|
python -m pytest -n 1 --dist=loadfile -s ./tests/ -m is_pipeline_test --durations=50
|
||||||
|
|
||||||
|
- name: Failure short reports
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: cat reports/report_test_tf_failures_short.txt
|
||||||
|
|
||||||
|
- name: Test suite reports artifacts
|
||||||
|
if: ${{ always() }}
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: run_all_tests_tf_multi_gpu_test_reports
|
||||||
|
path: reports
|
||||||
|
|
||||||
@@ -79,25 +79,31 @@ class TFAlbertEmbeddings(tf.keras.layers.Layer):
|
|||||||
def __init__(self, config, **kwargs):
|
def __init__(self, config, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
self.config = config
|
|
||||||
self.vocab_size = config.vocab_size
|
self.vocab_size = config.vocab_size
|
||||||
|
self.embedding_size = config.embedding_size
|
||||||
|
self.initializer_range = config.initializer_range
|
||||||
|
self.max_position_embeddings = config.max_position_embeddings
|
||||||
|
self.type_vocab_size = config.type_vocab_size
|
||||||
|
self.layer_norm_eps = config.layer_norm_eps
|
||||||
|
self.hidden_dropout_prob = config.hidden_dropout_prob
|
||||||
|
|
||||||
self.position_embeddings = tf.keras.layers.Embedding(
|
self.position_embeddings = tf.keras.layers.Embedding(
|
||||||
config.max_position_embeddings,
|
self.max_position_embeddings,
|
||||||
config.embedding_size,
|
self.embedding_size,
|
||||||
embeddings_initializer=get_initializer(self.config.initializer_range),
|
embeddings_initializer=get_initializer(self.initializer_range),
|
||||||
name="position_embeddings",
|
name="position_embeddings",
|
||||||
)
|
)
|
||||||
self.token_type_embeddings = tf.keras.layers.Embedding(
|
self.token_type_embeddings = tf.keras.layers.Embedding(
|
||||||
config.type_vocab_size,
|
self.type_vocab_size,
|
||||||
config.embedding_size,
|
self.embedding_size,
|
||||||
embeddings_initializer=get_initializer(self.config.initializer_range),
|
embeddings_initializer=get_initializer(self.initializer_range),
|
||||||
name="token_type_embeddings",
|
name="token_type_embeddings",
|
||||||
)
|
)
|
||||||
|
|
||||||
# self.LayerNorm is not snake-cased to stick with TensorFlow model variable name and be able to load
|
# self.LayerNorm is not snake-cased to stick with TensorFlow model variable name and be able to load
|
||||||
# any TensorFlow checkpoint file
|
# any TensorFlow checkpoint file
|
||||||
self.LayerNorm = tf.keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name="LayerNorm")
|
self.LayerNorm = tf.keras.layers.LayerNormalization(epsilon=self.layer_norm_eps, name="LayerNorm")
|
||||||
self.dropout = tf.keras.layers.Dropout(config.hidden_dropout_prob)
|
self.dropout = tf.keras.layers.Dropout(self.hidden_dropout_prob)
|
||||||
|
|
||||||
def build(self, input_shape):
|
def build(self, input_shape):
|
||||||
"""Build shared word embedding layer """
|
"""Build shared word embedding layer """
|
||||||
@@ -106,8 +112,8 @@ class TFAlbertEmbeddings(tf.keras.layers.Layer):
|
|||||||
# arbitrarily, and works well.
|
# arbitrarily, and works well.
|
||||||
self.word_embeddings = self.add_weight(
|
self.word_embeddings = self.add_weight(
|
||||||
"weight",
|
"weight",
|
||||||
shape=[self.config.vocab_size, self.config.embedding_size],
|
shape=[self.vocab_size, self.embedding_size],
|
||||||
initializer=get_initializer(self.config.initializer_range),
|
initializer=get_initializer(self.initializer_range),
|
||||||
)
|
)
|
||||||
super().build(input_shape)
|
super().build(input_shape)
|
||||||
|
|
||||||
@@ -182,9 +188,9 @@ class TFAlbertEmbeddings(tf.keras.layers.Layer):
|
|||||||
"""
|
"""
|
||||||
batch_size = shape_list(inputs)[0]
|
batch_size = shape_list(inputs)[0]
|
||||||
length = shape_list(inputs)[1]
|
length = shape_list(inputs)[1]
|
||||||
x = tf.reshape(inputs, [-1, self.config.embedding_size])
|
x = tf.reshape(inputs, [-1, self.embedding_size])
|
||||||
logits = tf.matmul(x, self.word_embeddings, transpose_b=True)
|
logits = tf.matmul(x, self.word_embeddings, transpose_b=True)
|
||||||
return tf.reshape(logits, [batch_size, length, self.config.vocab_size])
|
return tf.reshape(logits, [batch_size, length, self.vocab_size])
|
||||||
|
|
||||||
|
|
||||||
class TFAlbertSelfOutput(tf.keras.layers.Layer):
|
class TFAlbertSelfOutput(tf.keras.layers.Layer):
|
||||||
@@ -207,7 +213,7 @@ class TFAlbertAttention(tf.keras.layers.Layer):
|
|||||||
""" Contains the complete attention sublayer, including both dropouts and layer norm. """
|
""" Contains the complete attention sublayer, including both dropouts and layer norm. """
|
||||||
|
|
||||||
def __init__(self, config, **kwargs):
|
def __init__(self, config, **kwargs):
|
||||||
super().__init__(config, **kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
self.hidden_size = config.hidden_size
|
self.hidden_size = config.hidden_size
|
||||||
self.output_attentions = config.output_attentions
|
self.output_attentions = config.output_attentions
|
||||||
@@ -371,7 +377,8 @@ class TFAlbertTransformer(tf.keras.layers.Layer):
|
|||||||
def __init__(self, config, **kwargs):
|
def __init__(self, config, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
self.config = config
|
self.num_hidden_layers = config.num_hidden_layers
|
||||||
|
self.num_hidden_groups = config.num_hidden_groups
|
||||||
self.embedding_hidden_mapping_in = tf.keras.layers.Dense(
|
self.embedding_hidden_mapping_in = tf.keras.layers.Dense(
|
||||||
config.hidden_size,
|
config.hidden_size,
|
||||||
kernel_initializer=get_initializer(config.initializer_range),
|
kernel_initializer=get_initializer(config.initializer_range),
|
||||||
@@ -396,12 +403,12 @@ class TFAlbertTransformer(tf.keras.layers.Layer):
|
|||||||
all_attentions = () if output_attentions else None
|
all_attentions = () if output_attentions else None
|
||||||
all_hidden_states = (hidden_states,) if output_hidden_states else None
|
all_hidden_states = (hidden_states,) if output_hidden_states else None
|
||||||
|
|
||||||
for i in range(self.config.num_hidden_layers):
|
for i in range(self.num_hidden_layers):
|
||||||
# Number of layers in a hidden group
|
# Number of layers in a hidden group
|
||||||
layers_per_group = int(self.config.num_hidden_layers / self.config.num_hidden_groups)
|
layers_per_group = int(self.num_hidden_layers / self.num_hidden_groups)
|
||||||
|
|
||||||
# Index of the hidden group
|
# Index of the hidden group
|
||||||
group_idx = int(i / (self.config.num_hidden_layers / self.config.num_hidden_groups))
|
group_idx = int(i / (self.num_hidden_layers / self.num_hidden_groups))
|
||||||
|
|
||||||
layer_group_output = self.albert_layer_groups[group_idx](
|
layer_group_output = self.albert_layer_groups[group_idx](
|
||||||
hidden_states,
|
hidden_states,
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class TFFunnelAttentionStructure:
|
|||||||
pooled_pos = pos
|
pooled_pos = pos
|
||||||
|
|
||||||
ref_point = pooled_pos[0] - pos[0]
|
ref_point = pooled_pos[0] - pos[0]
|
||||||
num_remove = shift * len(pooled_pos)
|
num_remove = shift * pooled_pos.shape[0]
|
||||||
max_dist = ref_point + num_remove * stride
|
max_dist = ref_point + num_remove * stride
|
||||||
min_dist = pooled_pos[0] - pos[-1]
|
min_dist = pooled_pos[0] - pos[-1]
|
||||||
|
|
||||||
|
|||||||
@@ -1257,17 +1257,17 @@ class TFXLNetLMHeadModel(TFXLNetPreTrainedModel, TFCausalLanguageModelingLoss):
|
|||||||
|
|
||||||
transformer_outputs = self.transformer(
|
transformer_outputs = self.transformer(
|
||||||
inputs,
|
inputs,
|
||||||
attention_mask=None,
|
attention_mask=attention_mask,
|
||||||
mems=None,
|
mems=mems,
|
||||||
perm_mask=None,
|
perm_mask=perm_mask,
|
||||||
target_mapping=None,
|
target_mapping=target_mapping,
|
||||||
token_type_ids=None,
|
token_type_ids=token_type_ids,
|
||||||
input_mask=None,
|
input_mask=input_mask,
|
||||||
head_mask=None,
|
head_mask=head_mask,
|
||||||
inputs_embeds=None,
|
inputs_embeds=inputs_embeds,
|
||||||
use_cache=True,
|
use_cache=use_cache,
|
||||||
output_attentions=None,
|
output_attentions=output_attentions,
|
||||||
output_hidden_states=None,
|
output_hidden_states=output_hidden_states,
|
||||||
return_dict=return_dict,
|
return_dict=return_dict,
|
||||||
training=training,
|
training=training,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from transformers.testing_utils import require_tf, require_torch, slow
|
|||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skip("Temporarily disable the doc tests.")
|
||||||
@require_torch
|
@require_torch
|
||||||
@require_tf
|
@require_tf
|
||||||
@slow
|
@slow
|
||||||
|
|||||||
@@ -1087,6 +1087,10 @@ class ModelUtilsTest(unittest.TestCase):
|
|||||||
self.assertEqual(len(value), 0)
|
self.assertEqual(len(value), 0)
|
||||||
|
|
||||||
config = BertConfig.from_pretrained(model_name, output_attentions=True, output_hidden_states=True)
|
config = BertConfig.from_pretrained(model_name, output_attentions=True, output_hidden_states=True)
|
||||||
|
|
||||||
|
# Not sure this is the intended behavior. TODO fix Lysandre & Thom
|
||||||
|
config.name_or_path = model_name
|
||||||
|
|
||||||
model = BertModel.from_pretrained(model_name, output_attentions=True, output_hidden_states=True)
|
model = BertModel.from_pretrained(model_name, output_attentions=True, output_hidden_states=True)
|
||||||
self.assertEqual(model.config.output_hidden_states, True)
|
self.assertEqual(model.config.output_hidden_states, True)
|
||||||
self.assertEqual(model.config, config)
|
self.assertEqual(model.config, config)
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class SelectiveCommonTest(unittest.TestCase):
|
|||||||
|
|
||||||
class ModelManagementTests(unittest.TestCase):
|
class ModelManagementTests(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
|
@require_torch
|
||||||
def test_model_names(self):
|
def test_model_names(self):
|
||||||
model_list = HfApi().model_list()
|
model_list = HfApi().model_list()
|
||||||
model_ids = [x.modelId for x in model_list if x.modelId.startswith(ORG_NAME)]
|
model_ids = [x.modelId for x in model_list if x.modelId.startswith(ORG_NAME)]
|
||||||
|
|||||||
@@ -959,6 +959,7 @@ class ProphetNetStandaloneEncoderModelTest(ModelTesterMixin, unittest.TestCase):
|
|||||||
self.config_tester.run_common_tests()
|
self.config_tester.run_common_tests()
|
||||||
|
|
||||||
|
|
||||||
|
@require_torch
|
||||||
class ProphetNetModelIntegrationTest(unittest.TestCase):
|
class ProphetNetModelIntegrationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_pretrained_checkpoint_hidden_states(self):
|
def test_pretrained_checkpoint_hidden_states(self):
|
||||||
|
|||||||
@@ -25,7 +25,14 @@ import numpy as np
|
|||||||
|
|
||||||
from transformers import BartTokenizer, T5Tokenizer
|
from transformers import BartTokenizer, T5Tokenizer
|
||||||
from transformers.file_utils import cached_property, is_datasets_available, is_faiss_available, is_torch_available
|
from transformers.file_utils import cached_property, is_datasets_available, is_faiss_available, is_torch_available
|
||||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
from transformers.testing_utils import (
|
||||||
|
require_sentencepiece,
|
||||||
|
require_tokenizers,
|
||||||
|
require_torch,
|
||||||
|
require_torch_non_multigpu,
|
||||||
|
slow,
|
||||||
|
torch_device,
|
||||||
|
)
|
||||||
from transformers.tokenization_bert import VOCAB_FILES_NAMES as DPR_VOCAB_FILES_NAMES
|
from transformers.tokenization_bert import VOCAB_FILES_NAMES as DPR_VOCAB_FILES_NAMES
|
||||||
from transformers.tokenization_dpr import DPRQuestionEncoderTokenizer
|
from transformers.tokenization_dpr import DPRQuestionEncoderTokenizer
|
||||||
from transformers.tokenization_roberta import VOCAB_FILES_NAMES as BART_VOCAB_FILES_NAMES
|
from transformers.tokenization_roberta import VOCAB_FILES_NAMES as BART_VOCAB_FILES_NAMES
|
||||||
@@ -574,6 +581,7 @@ class RagDPRT5Test(RagTestMixin, unittest.TestCase):
|
|||||||
@require_retrieval
|
@require_retrieval
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@require_torch_non_multigpu
|
||||||
class RagModelIntegrationTests(unittest.TestCase):
|
class RagModelIntegrationTests(unittest.TestCase):
|
||||||
@cached_property
|
@cached_property
|
||||||
def sequence_model(self):
|
def sequence_model(self):
|
||||||
|
|||||||
@@ -396,6 +396,7 @@ class RobertaModelTest(ModelTesterMixin, unittest.TestCase):
|
|||||||
|
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@require_torch
|
||||||
class RobertaModelIntegrationTest(unittest.TestCase):
|
class RobertaModelIntegrationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_inference_masked_lm(self):
|
def test_inference_masked_lm(self):
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ class SqueezeBertModelTest(ModelTesterMixin, unittest.TestCase):
|
|||||||
|
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@require_torch
|
||||||
class SqueezeBertModelIntegrationTest(unittest.TestCase):
|
class SqueezeBertModelIntegrationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_inference_classification_head(self):
|
def test_inference_classification_head(self):
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class TFCamembertModelIntegrationTest(unittest.TestCase):
|
|||||||
dtype=tf.int32,
|
dtype=tf.int32,
|
||||||
) # J'aime le camembert !"
|
) # J'aime le camembert !"
|
||||||
|
|
||||||
output = model(input_ids)["last_hidden_state"]
|
output = model(input_ids, return_dict=True)["last_hidden_state"]
|
||||||
expected_shape = tf.TensorShape((1, 10, 768))
|
expected_shape = tf.TensorShape((1, 10, 768))
|
||||||
self.assertEqual(output.shape, expected_shape)
|
self.assertEqual(output.shape, expected_shape)
|
||||||
# compare the actual values for a slice.
|
# compare the actual values for a slice.
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class TFModelTesterMixin:
|
|||||||
test_resize_embeddings = True
|
test_resize_embeddings = True
|
||||||
is_encoder_decoder = False
|
is_encoder_decoder = False
|
||||||
|
|
||||||
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False):
|
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False) -> dict:
|
||||||
inputs_dict = copy.deepcopy(inputs_dict)
|
inputs_dict = copy.deepcopy(inputs_dict)
|
||||||
|
|
||||||
if model_class in TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING.values():
|
if model_class in TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING.values():
|
||||||
@@ -165,16 +165,16 @@ class TFModelTesterMixin:
|
|||||||
config.output_hidden_states = True
|
config.output_hidden_states = True
|
||||||
|
|
||||||
for model_class in self.all_model_classes:
|
for model_class in self.all_model_classes:
|
||||||
inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
class_inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
||||||
model = model_class(config)
|
model = model_class(config)
|
||||||
num_out = len(model(inputs_dict))
|
num_out = len(model(class_inputs_dict))
|
||||||
model._saved_model_inputs_spec = None
|
model._saved_model_inputs_spec = None
|
||||||
model._set_save_spec(inputs_dict)
|
model._set_save_spec(class_inputs_dict)
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
tf.saved_model.save(model, tmpdirname)
|
tf.saved_model.save(model, tmpdirname)
|
||||||
model = tf.keras.models.load_model(tmpdirname)
|
model = tf.keras.models.load_model(tmpdirname)
|
||||||
outputs = model(inputs_dict)
|
outputs = model(class_inputs_dict)
|
||||||
|
|
||||||
if self.is_encoder_decoder:
|
if self.is_encoder_decoder:
|
||||||
output = outputs["encoder_hidden_states"] if isinstance(outputs, dict) else outputs[-1]
|
output = outputs["encoder_hidden_states"] if isinstance(outputs, dict) else outputs[-1]
|
||||||
@@ -183,7 +183,10 @@ class TFModelTesterMixin:
|
|||||||
|
|
||||||
hidden_states = [t.numpy() for t in output]
|
hidden_states = [t.numpy() for t in output]
|
||||||
self.assertEqual(len(outputs), num_out)
|
self.assertEqual(len(outputs), num_out)
|
||||||
self.assertEqual(len(hidden_states), self.model_tester.num_hidden_layers + 1)
|
expected_num_layers = getattr(
|
||||||
|
self.model_tester, "expected_num_hidden_layers", self.model_tester.num_hidden_layers + 1
|
||||||
|
)
|
||||||
|
self.assertEqual(len(hidden_states), expected_num_layers)
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
list(hidden_states[0].shape[-2:]),
|
list(hidden_states[0].shape[-2:]),
|
||||||
[self.model_tester.seq_length, self.model_tester.hidden_size],
|
[self.model_tester.seq_length, self.model_tester.hidden_size],
|
||||||
@@ -193,26 +196,21 @@ class TFModelTesterMixin:
|
|||||||
def test_saved_model_with_attentions_output(self):
|
def test_saved_model_with_attentions_output(self):
|
||||||
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
||||||
config.output_attentions = True
|
config.output_attentions = True
|
||||||
encoder_seq_length = (
|
|
||||||
self.model_tester.encoder_seq_length
|
encoder_seq_length = getattr(self.model_tester, "encoder_seq_length", self.model_tester.seq_length)
|
||||||
if hasattr(self.model_tester, "encoder_seq_length")
|
encoder_key_length = getattr(self.model_tester, "key_length", encoder_seq_length)
|
||||||
else self.model_tester.seq_length
|
|
||||||
)
|
|
||||||
encoder_key_length = (
|
|
||||||
self.model_tester.key_length if hasattr(self.model_tester, "key_length") else encoder_seq_length
|
|
||||||
)
|
|
||||||
|
|
||||||
for model_class in self.all_model_classes:
|
for model_class in self.all_model_classes:
|
||||||
inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
class_inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
||||||
model = model_class(config)
|
model = model_class(config)
|
||||||
num_out = len(model(inputs_dict))
|
num_out = len(model(class_inputs_dict))
|
||||||
model._saved_model_inputs_spec = None
|
model._saved_model_inputs_spec = None
|
||||||
model._set_save_spec(inputs_dict)
|
model._set_save_spec(class_inputs_dict)
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
tf.saved_model.save(model, tmpdirname)
|
tf.saved_model.save(model, tmpdirname)
|
||||||
model = tf.keras.models.load_model(tmpdirname)
|
model = tf.keras.models.load_model(tmpdirname)
|
||||||
outputs = model(inputs_dict)
|
outputs = model(class_inputs_dict)
|
||||||
|
|
||||||
if self.is_encoder_decoder:
|
if self.is_encoder_decoder:
|
||||||
output = outputs["encoder_attentions"] if isinstance(outputs, dict) else outputs[-1]
|
output = outputs["encoder_attentions"] if isinstance(outputs, dict) else outputs[-1]
|
||||||
|
|||||||
@@ -330,6 +330,14 @@ class TFFlaubertModelTest(TFModelTesterMixin, unittest.TestCase):
|
|||||||
model = TFFlaubertModel.from_pretrained(model_name)
|
model = TFFlaubertModel.from_pretrained(model_name)
|
||||||
self.assertIsNotNone(model)
|
self.assertIsNotNone(model)
|
||||||
|
|
||||||
|
def test_saved_model_with_hidden_states_output(self):
|
||||||
|
# Should be uncommented during patrick TF refactor
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_saved_model_with_attentions_output(self):
|
||||||
|
# Should be uncommented during patrick TF refactor
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@require_tf
|
@require_tf
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
|
|||||||
@@ -302,6 +302,10 @@ class TFLongformerModelTest(TFModelTesterMixin, unittest.TestCase):
|
|||||||
config_and_inputs = self.model_tester.prepare_config_and_inputs_for_question_answering()
|
config_and_inputs = self.model_tester.prepare_config_and_inputs_for_question_answering()
|
||||||
self.model_tester.create_and_check_longformer_for_question_answering(*config_and_inputs)
|
self.model_tester.create_and_check_longformer_for_question_answering(*config_and_inputs)
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_saved_model_with_attentions_output(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@require_tf
|
@require_tf
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
|
|||||||
@@ -678,3 +678,79 @@ class TFLxmertModelTest(TFModelTesterMixin, unittest.TestCase):
|
|||||||
# Compile extended model
|
# Compile extended model
|
||||||
extended_model = tf.keras.Model(inputs=[input_ids, visual_feats, visual_pos], outputs=[outputs])
|
extended_model = tf.keras.Model(inputs=[input_ids, visual_feats, visual_pos], outputs=[outputs])
|
||||||
extended_model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
|
extended_model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_saved_model_with_hidden_states_output(self):
|
||||||
|
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
||||||
|
config.output_hidden_states = True
|
||||||
|
|
||||||
|
for model_class in self.all_model_classes:
|
||||||
|
class_inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
||||||
|
model = model_class(config)
|
||||||
|
model._saved_model_inputs_spec = None
|
||||||
|
model._set_save_spec(class_inputs_dict)
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
|
tf.saved_model.save(model, tmpdirname)
|
||||||
|
model = tf.keras.models.load_model(tmpdirname)
|
||||||
|
outputs = model(class_inputs_dict)
|
||||||
|
|
||||||
|
language_hidden_states, vision_hidden_states = outputs[-2], outputs[-1]
|
||||||
|
|
||||||
|
self.assertEqual(len(language_hidden_states), self.model_tester.num_hidden_layers["language"] + 1)
|
||||||
|
self.assertEqual(len(vision_hidden_states), self.model_tester.num_hidden_layers["vision"] + 1)
|
||||||
|
|
||||||
|
seq_length = self.model_tester.seq_length
|
||||||
|
num_visual_features = self.model_tester.num_visual_features
|
||||||
|
|
||||||
|
self.assertListEqual(
|
||||||
|
list(language_hidden_states[0].shape[-2:]),
|
||||||
|
[seq_length, self.model_tester.hidden_size],
|
||||||
|
)
|
||||||
|
self.assertListEqual(
|
||||||
|
list(vision_hidden_states[0].shape[-2:]),
|
||||||
|
[num_visual_features, self.model_tester.hidden_size],
|
||||||
|
)
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_saved_model_with_attentions_output(self):
|
||||||
|
config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common()
|
||||||
|
config.output_attentions = True
|
||||||
|
|
||||||
|
encoder_seq_length = getattr(self.model_tester, "encoder_seq_length", self.model_tester.seq_length)
|
||||||
|
encoder_key_length = getattr(self.model_tester, "key_length", encoder_seq_length)
|
||||||
|
|
||||||
|
for model_class in self.all_model_classes:
|
||||||
|
class_inputs_dict = self._prepare_for_class(inputs_dict, model_class)
|
||||||
|
model = model_class(config)
|
||||||
|
model._saved_model_inputs_spec = None
|
||||||
|
model._set_save_spec(class_inputs_dict)
|
||||||
|
|
||||||
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
|
tf.saved_model.save(model, tmpdirname)
|
||||||
|
model = tf.keras.models.load_model(tmpdirname)
|
||||||
|
outputs = model(class_inputs_dict)
|
||||||
|
|
||||||
|
language_attentions, vision_attentions, cross_encoder_attentions = (
|
||||||
|
outputs[-3],
|
||||||
|
outputs[-2],
|
||||||
|
outputs[-1],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(len(language_attentions), self.model_tester.num_hidden_layers["language"])
|
||||||
|
self.assertEqual(len(vision_attentions), self.model_tester.num_hidden_layers["vision"])
|
||||||
|
self.assertEqual(len(cross_encoder_attentions), self.model_tester.num_hidden_layers["cross_encoder"])
|
||||||
|
|
||||||
|
attentions = [language_attentions, vision_attentions, cross_encoder_attentions]
|
||||||
|
attention_shapes = [
|
||||||
|
[self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length],
|
||||||
|
[
|
||||||
|
self.model_tester.num_attention_heads,
|
||||||
|
self.model_tester.num_visual_features,
|
||||||
|
self.model_tester.num_visual_features,
|
||||||
|
],
|
||||||
|
[self.model_tester.num_attention_heads, encoder_key_length, self.model_tester.num_visual_features],
|
||||||
|
]
|
||||||
|
|
||||||
|
for attention, attention_shape in zip(attentions, attention_shapes):
|
||||||
|
self.assertListEqual(list(attention[0].shape[-3:]), attention_shape)
|
||||||
|
|||||||
@@ -287,6 +287,6 @@ class TFMobileBertModelTest(TFModelTesterMixin, unittest.TestCase):
|
|||||||
@slow
|
@slow
|
||||||
def test_model_from_pretrained(self):
|
def test_model_from_pretrained(self):
|
||||||
# for model_name in TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
# for model_name in TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||||
for model_name in ["mobilebert-uncased"]:
|
for model_name in ["google/mobilebert-uncased"]:
|
||||||
model = TFMobileBertModel.from_pretrained(model_name)
|
model = TFMobileBertModel.from_pretrained(model_name)
|
||||||
self.assertIsNotNone(model)
|
self.assertIsNotNone(model)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from transformers import T5Config, is_tf_available
|
from transformers import T5Config, is_tf_available
|
||||||
@@ -282,6 +280,14 @@ class TFT5ModelTest(TFModelTesterMixin, unittest.TestCase):
|
|||||||
model = TFT5Model.from_pretrained("t5-small")
|
model = TFT5Model.from_pretrained("t5-small")
|
||||||
self.assertIsNotNone(model)
|
self.assertIsNotNone(model)
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_saved_model_with_attentions_output(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@slow
|
||||||
|
def test_saved_model_with_hidden_states_output(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@require_tf
|
@require_tf
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class TFFlaubertModelIntegrationTest(unittest.TestCase):
|
|||||||
"attention_mask": tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]], dtype=tf.int32),
|
"attention_mask": tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]], dtype=tf.int32),
|
||||||
}
|
}
|
||||||
|
|
||||||
output = model(features)["last_hidden_state"]
|
output = model(features, return_dict=True)["last_hidden_state"]
|
||||||
expected_shape = tf.TensorShape((1, 6, 768))
|
expected_shape = tf.TensorShape((1, 6, 768))
|
||||||
self.assertEqual(output.shape, expected_shape)
|
self.assertEqual(output.shape, expected_shape)
|
||||||
# compare the actual values for a slice.
|
# compare the actual values for a slice.
|
||||||
|
|||||||
@@ -279,6 +279,7 @@ class TransfoXLModelTest(ModelTesterMixin, unittest.TestCase):
|
|||||||
self.assertEqual(model_embed.emb_layers[layer].weight.shape[0], cloned_embeddings[layer].shape[0])
|
self.assertEqual(model_embed.emb_layers[layer].weight.shape[0], cloned_embeddings[layer].shape[0])
|
||||||
|
|
||||||
|
|
||||||
|
@require_torch
|
||||||
class TransfoXLModelLanguageGenerationTest(unittest.TestCase):
|
class TransfoXLModelLanguageGenerationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_lm_generate_transfo_xl_wt103(self):
|
def test_lm_generate_transfo_xl_wt103(self):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from transformers import is_torch_available
|
from transformers import is_torch_available
|
||||||
from transformers.testing_utils import slow, torch_device
|
from transformers.testing_utils import require_torch, slow, torch_device
|
||||||
|
|
||||||
|
|
||||||
if is_torch_available():
|
if is_torch_available():
|
||||||
@@ -26,6 +26,7 @@ if is_torch_available():
|
|||||||
from transformers import XLMProphetNetForConditionalGeneration, XLMProphetNetTokenizer
|
from transformers import XLMProphetNetForConditionalGeneration, XLMProphetNetTokenizer
|
||||||
|
|
||||||
|
|
||||||
|
@require_torch
|
||||||
class XLMProphetNetModelIntegrationTest(unittest.TestCase):
|
class XLMProphetNetModelIntegrationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_pretrained_checkpoint_hidden_states(self):
|
def test_pretrained_checkpoint_hidden_states(self):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from transformers import is_torch_available
|
from transformers import is_torch_available
|
||||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow
|
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow
|
||||||
|
|
||||||
|
|
||||||
if is_torch_available():
|
if is_torch_available():
|
||||||
@@ -28,6 +28,7 @@ if is_torch_available():
|
|||||||
|
|
||||||
@require_sentencepiece
|
@require_sentencepiece
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@require_torch
|
||||||
class XLMRobertaModelIntegrationTest(unittest.TestCase):
|
class XLMRobertaModelIntegrationTest(unittest.TestCase):
|
||||||
@slow
|
@slow
|
||||||
def test_xlm_roberta_base(self):
|
def test_xlm_roberta_base(self):
|
||||||
|
|||||||
@@ -95,26 +95,28 @@ class OnnxExportTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
@require_torch
|
@require_torch
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@slow
|
||||||
def test_infer_dynamic_axis_pytorch(self):
|
def test_infer_dynamic_axis_pytorch(self):
|
||||||
"""
|
"""
|
||||||
Validate the dynamic axis generated for each parameters are correct
|
Validate the dynamic axis generated for each parameters are correct
|
||||||
"""
|
"""
|
||||||
from transformers import BertModel
|
from transformers import BertModel
|
||||||
|
|
||||||
model = BertModel(BertConfig.from_pretrained("bert-base-cased"))
|
model = BertModel(BertConfig.from_pretrained("lysandre/tiny-bert-random"))
|
||||||
tokenizer = BertTokenizerFast.from_pretrained("bert-base-cased")
|
tokenizer = BertTokenizerFast.from_pretrained("lysandre/tiny-bert-random")
|
||||||
self._test_infer_dynamic_axis(model, tokenizer, "pt")
|
self._test_infer_dynamic_axis(model, tokenizer, "pt")
|
||||||
|
|
||||||
@require_tf
|
@require_tf
|
||||||
@require_tokenizers
|
@require_tokenizers
|
||||||
|
@slow
|
||||||
def test_infer_dynamic_axis_tf(self):
|
def test_infer_dynamic_axis_tf(self):
|
||||||
"""
|
"""
|
||||||
Validate the dynamic axis generated for each parameters are correct
|
Validate the dynamic axis generated for each parameters are correct
|
||||||
"""
|
"""
|
||||||
from transformers import TFBertModel
|
from transformers import TFBertModel
|
||||||
|
|
||||||
model = TFBertModel(BertConfig.from_pretrained("bert-base-cased"))
|
model = TFBertModel(BertConfig.from_pretrained("lysandre/tiny-bert-random"))
|
||||||
tokenizer = BertTokenizerFast.from_pretrained("bert-base-cased")
|
tokenizer = BertTokenizerFast.from_pretrained("lysandre/tiny-bert-random")
|
||||||
self._test_infer_dynamic_axis(model, tokenizer, "tf")
|
self._test_infer_dynamic_axis(model, tokenizer, "tf")
|
||||||
|
|
||||||
def _test_infer_dynamic_axis(self, model, tokenizer, framework):
|
def _test_infer_dynamic_axis(self, model, tokenizer, framework):
|
||||||
|
|||||||
@@ -96,21 +96,53 @@ class FillMaskPipelineTests(MonoInputPipelineCommonMixin, unittest.TestCase):
|
|||||||
framework="pt",
|
framework="pt",
|
||||||
topk=2,
|
topk=2,
|
||||||
)
|
)
|
||||||
self._test_mono_column_pipeline(
|
|
||||||
nlp,
|
mono_result = nlp(valid_inputs[0], targets=valid_targets)
|
||||||
valid_inputs,
|
self.assertIsInstance(mono_result, list)
|
||||||
mandatory_keys,
|
self.assertIsInstance(mono_result[0], dict)
|
||||||
expected_multi_result=EXPECTED_FILL_MASK_RESULT,
|
|
||||||
expected_check_keys=["sequence"],
|
for mandatory_key in mandatory_keys:
|
||||||
)
|
self.assertIn(mandatory_key, mono_result[0])
|
||||||
self._test_mono_column_pipeline(
|
|
||||||
nlp,
|
multi_result = [nlp(valid_input) for valid_input in valid_inputs]
|
||||||
valid_inputs[:1],
|
self.assertIsInstance(multi_result, list)
|
||||||
mandatory_keys,
|
self.assertIsInstance(multi_result[0], (dict, list))
|
||||||
expected_multi_result=EXPECTED_FILL_MASK_TARGET_RESULT,
|
|
||||||
expected_check_keys=["sequence"],
|
for result, expected in zip(multi_result, EXPECTED_FILL_MASK_RESULT):
|
||||||
targets=valid_targets,
|
self.assertEqual(set([o["sequence"] for o in result]), set([o["sequence"] for o in result]))
|
||||||
)
|
|
||||||
|
if isinstance(multi_result[0], list):
|
||||||
|
multi_result = multi_result[0]
|
||||||
|
|
||||||
|
for result in multi_result:
|
||||||
|
for key in mandatory_keys:
|
||||||
|
self.assertIn(key, result)
|
||||||
|
|
||||||
|
self.assertRaises(Exception, nlp, [None])
|
||||||
|
|
||||||
|
valid_inputs = valid_inputs[:1]
|
||||||
|
mono_result = nlp(valid_inputs[0], targets=valid_targets)
|
||||||
|
self.assertIsInstance(mono_result, list)
|
||||||
|
self.assertIsInstance(mono_result[0], dict)
|
||||||
|
|
||||||
|
for mandatory_key in mandatory_keys:
|
||||||
|
self.assertIn(mandatory_key, mono_result[0])
|
||||||
|
|
||||||
|
multi_result = [nlp(valid_input) for valid_input in valid_inputs]
|
||||||
|
self.assertIsInstance(multi_result, list)
|
||||||
|
self.assertIsInstance(multi_result[0], (dict, list))
|
||||||
|
|
||||||
|
for result, expected in zip(multi_result, EXPECTED_FILL_MASK_TARGET_RESULT):
|
||||||
|
self.assertEqual(set([o["sequence"] for o in result]), set([o["sequence"] for o in result]))
|
||||||
|
|
||||||
|
if isinstance(multi_result[0], list):
|
||||||
|
multi_result = multi_result[0]
|
||||||
|
|
||||||
|
for result in multi_result:
|
||||||
|
for key in mandatory_keys:
|
||||||
|
self.assertIn(key, result)
|
||||||
|
|
||||||
|
self.assertRaises(Exception, nlp, [None])
|
||||||
|
|
||||||
@require_tf
|
@require_tf
|
||||||
@slow
|
@slow
|
||||||
@@ -123,18 +155,50 @@ class FillMaskPipelineTests(MonoInputPipelineCommonMixin, unittest.TestCase):
|
|||||||
valid_targets = [" Patrick", " Clara"]
|
valid_targets = [" Patrick", " Clara"]
|
||||||
for model_name in self.large_models:
|
for model_name in self.large_models:
|
||||||
nlp = pipeline(task="fill-mask", model=model_name, tokenizer=model_name, framework="tf", topk=2)
|
nlp = pipeline(task="fill-mask", model=model_name, tokenizer=model_name, framework="tf", topk=2)
|
||||||
self._test_mono_column_pipeline(
|
|
||||||
nlp,
|
mono_result = nlp(valid_inputs[0], targets=valid_targets)
|
||||||
valid_inputs,
|
self.assertIsInstance(mono_result, list)
|
||||||
mandatory_keys,
|
self.assertIsInstance(mono_result[0], dict)
|
||||||
expected_multi_result=EXPECTED_FILL_MASK_RESULT,
|
|
||||||
expected_check_keys=["sequence"],
|
for mandatory_key in mandatory_keys:
|
||||||
)
|
self.assertIn(mandatory_key, mono_result[0])
|
||||||
self._test_mono_column_pipeline(
|
|
||||||
nlp,
|
multi_result = [nlp(valid_input) for valid_input in valid_inputs]
|
||||||
valid_inputs[:1],
|
self.assertIsInstance(multi_result, list)
|
||||||
mandatory_keys,
|
self.assertIsInstance(multi_result[0], (dict, list))
|
||||||
expected_multi_result=EXPECTED_FILL_MASK_TARGET_RESULT,
|
|
||||||
expected_check_keys=["sequence"],
|
for result, expected in zip(multi_result, EXPECTED_FILL_MASK_RESULT):
|
||||||
targets=valid_targets,
|
self.assertEqual(set([o["sequence"] for o in result]), set([o["sequence"] for o in result]))
|
||||||
)
|
|
||||||
|
if isinstance(multi_result[0], list):
|
||||||
|
multi_result = multi_result[0]
|
||||||
|
|
||||||
|
for result in multi_result:
|
||||||
|
for key in mandatory_keys:
|
||||||
|
self.assertIn(key, result)
|
||||||
|
|
||||||
|
self.assertRaises(Exception, nlp, [None])
|
||||||
|
|
||||||
|
valid_inputs = valid_inputs[:1]
|
||||||
|
mono_result = nlp(valid_inputs[0], targets=valid_targets)
|
||||||
|
self.assertIsInstance(mono_result, list)
|
||||||
|
self.assertIsInstance(mono_result[0], dict)
|
||||||
|
|
||||||
|
for mandatory_key in mandatory_keys:
|
||||||
|
self.assertIn(mandatory_key, mono_result[0])
|
||||||
|
|
||||||
|
multi_result = [nlp(valid_input) for valid_input in valid_inputs]
|
||||||
|
self.assertIsInstance(multi_result, list)
|
||||||
|
self.assertIsInstance(multi_result[0], (dict, list))
|
||||||
|
|
||||||
|
for result, expected in zip(multi_result, EXPECTED_FILL_MASK_TARGET_RESULT):
|
||||||
|
self.assertEqual(set([o["sequence"] for o in result]), set([o["sequence"] for o in result]))
|
||||||
|
|
||||||
|
if isinstance(multi_result[0], list):
|
||||||
|
multi_result = multi_result[0]
|
||||||
|
|
||||||
|
for result in multi_result:
|
||||||
|
for key in mandatory_keys:
|
||||||
|
self.assertIn(key, result)
|
||||||
|
|
||||||
|
self.assertRaises(Exception, nlp, [None])
|
||||||
|
|||||||
Reference in New Issue
Block a user