Skip to content

Commit 6718e3c

Browse files
huydhnpytorchmergebot
authored andcommitted
Cache the transformers model used in ONNX test (pytorch#96793)
Also updating merge_rule to allow ONNX exporter team to update the Docker script by themselves. By default, the model is cached at ~/.cache/huggingface/hub/ under CI jenkins user. The model is cached so that we don't need to re-download it every time in CI, which causes flaky [CI failures](https://hud.pytorch.org/failure/FAILED%20test%2Fonnx%2Ftest_fx_to_onnx_with_onnxruntime.py%3A%3ATestFxToOnnxWithOnnxRuntime%3A%3Atest_large_scale_exporter_with_tiny_gpt2%20-%20requests.exceptions.ReadTimeout%3A%20HTTPSConnectionPool(host%3D'huggingface.co'%2C%20port%3D443)%3A%20Read%20timed%20out.%20(read%20timeout%3D10.0)). This is the second part after pytorch#96590 ### Testing Confirm that the model is cached in the Docker image before running the test: ``` jenkins@dd0db85dd34f:~/workspace$ ls -la ~/.cache/huggingface/hub/models--sshleifer--tiny-gpt2/* /var/lib/jenkins/.cache/huggingface/hub/models--sshleifer--tiny-gpt2/blobs: total 2460 drwxrwxr-x 2 jenkins jenkins 126 Mar 15 05:48 . drwxrwxr-x 5 jenkins jenkins 48 Mar 15 05:48 .. -rw-rw-r-- 1 jenkins jenkins 662 Mar 15 05:48 2c81a6c4c984e95a45338c64a7445c1f0f88077f -rw-rw-r-- 1 jenkins jenkins 2514146 Mar 15 05:48 b706b24034032bdfe765ded5ab6403d201d295a995b790cb24c74becca5c04e6 /var/lib/jenkins/.cache/huggingface/hub/models--sshleifer--tiny-gpt2/refs: total 4 drwxrwxr-x 2 jenkins jenkins 18 Mar 15 05:48 . drwxrwxr-x 5 jenkins jenkins 48 Mar 15 05:48 .. -rw-rw-r-- 1 jenkins jenkins 40 Mar 15 05:48 main /var/lib/jenkins/.cache/huggingface/hub/models--sshleifer--tiny-gpt2/snapshots: total 0 drwxrwxr-x 3 jenkins jenkins 54 Mar 15 05:48 . drwxrwxr-x 5 jenkins jenkins 48 Mar 15 05:48 .. drwxrwxr-x 2 jenkins jenkins 50 Mar 15 05:48 5f91d94bd9cd7190a9f3216ff93cd1dd95f2c7be ``` Pull Request resolved: pytorch#96793 Approved by: https://github.com/titaiwangms, https://github.com/ZainRizvi
1 parent aeb3db8 commit 6718e3c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.ci/docker/common/install_onnx.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ pip_install \
2323

2424
# TODO: change this when onnx-script is on testPypi
2525
pip_install "onnx-script@git+https://github.com/microsoft/onnx-script@29241e15f5182be1384f1cf6ba203d7e2e125196"
26+
27+
# Cache the transformers model to be used later by ONNX tests. We need to run the transformers
28+
# package to download the model. By default, the model is cached at ~/.cache/huggingface/hub/
29+
IMPORT_SCRIPT_FILENAME="/tmp/onnx_import_script.py"
30+
as_jenkins echo 'import transformers; transformers.AutoModel.from_pretrained("sshleifer/tiny-gpt2");' > "${IMPORT_SCRIPT_FILENAME}"
31+
32+
# Need a PyTorch version for transformers to work
33+
pip_install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
34+
# Very weird quoting behavior here https://github.com/conda/conda/issues/10972,
35+
# so echo the command to a file and run the file instead
36+
conda_run python "${IMPORT_SCRIPT_FILENAME}"
37+
38+
# Cleaning up
39+
conda_run pip uninstall -y torch
40+
rm "${IMPORT_SCRIPT_FILENAME}" || true

.github/merge_rules.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
patterns:
33
- .ci/caffe2/*
44
- .ci/onnx/*
5+
- .ci/docker/common/install_onnx.sh
56
- aten/src/ATen/core/interned_strings.h
67
- docs/source/onnx.rst
78
- docs/source/onnx*

0 commit comments

Comments
 (0)