2020-07-02 01:44:19 +00:00
|
|
|
local base = import 'templates/base.libsonnet';
|
|
|
|
local tpus = import 'templates/tpus.libsonnet';
|
|
|
|
local utils = import "templates/utils.libsonnet";
|
|
|
|
|
|
|
|
local tputests = base.BaseTest {
|
|
|
|
frameworkPrefix: 'pl',
|
|
|
|
modelName: 'tpu-tests',
|
|
|
|
mode: 'postsubmit',
|
|
|
|
configMaps: [],
|
|
|
|
|
2022-07-27 15:40:40 +00:00
|
|
|
timeout: 6000, # 100 minutes, in seconds.
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2021-07-19 14:13:21 +00:00
|
|
|
image: 'pytorchlightning/pytorch_lightning',
|
|
|
|
imageTag: 'base-xla-py{PYTHON_VERSION}-torch{PYTORCH_VERSION}',
|
2020-07-02 01:44:19 +00:00
|
|
|
|
|
|
|
tpuSettings+: {
|
2021-07-19 14:13:21 +00:00
|
|
|
softwareVersion: 'pytorch-{PYTORCH_VERSION}',
|
2020-07-02 01:44:19 +00:00
|
|
|
},
|
|
|
|
accelerator: tpus.v3_8,
|
|
|
|
|
|
|
|
command: utils.scriptCommand(
|
|
|
|
|||
|
2022-10-03 13:13:33 +00:00
|
|
|
set +x # turn off tracing, spammy
|
|
|
|
set -e # exit on error
|
|
|
|
|
2021-07-19 14:13:21 +00:00
|
|
|
source ~/.bashrc
|
|
|
|
conda activate lightning
|
2022-10-03 13:13:33 +00:00
|
|
|
|
2022-12-06 17:00:15 +00:00
|
|
|
echo "--- Cloning lightning repo ---"
|
2022-10-21 18:01:39 +00:00
|
|
|
git clone --single-branch --depth 1 https://github.com/Lightning-AI/lightning.git
|
|
|
|
cd lightning
|
2022-12-06 17:00:15 +00:00
|
|
|
# PR triggered it, check it out
|
2022-10-31 15:58:02 +00:00
|
|
|
if [ -n "{PR_NUMBER}" ]; then # if PR number is not empty
|
2022-12-06 17:00:15 +00:00
|
|
|
echo "--- Fetch the PR changes ---"
|
2022-10-31 15:58:02 +00:00
|
|
|
git fetch origin --depth 1 pull/{PR_NUMBER}/head:test/{PR_NUMBER}
|
2022-12-06 17:00:15 +00:00
|
|
|
echo "--- Checkout PR changes ---"
|
2022-10-31 15:58:02 +00:00
|
|
|
git -c advice.detachedHead=false checkout {SHA}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "--- Install packages ---"
|
2023-02-02 19:01:53 +00:00
|
|
|
# set particular PyTorch version
|
|
|
|
for fpath in `ls requirements/**/*.txt`; do
|
|
|
|
python requirements/pytorch/adjust-versions.py $fpath {PYTORCH_VERSION};
|
|
|
|
done
|
2023-01-04 15:57:18 +00:00
|
|
|
PACKAGE_NAME=fabric pip install .[dev]
|
2022-10-03 13:13:33 +00:00
|
|
|
pip list
|
|
|
|
|
2023-02-01 20:34:38 +00:00
|
|
|
pip install -q -r .actions/requirements.txt
|
|
|
|
python .actions/assistant.py copy_replace_imports --source_dir="./tests" --source_import="lightning.fabric" --target_import="lightning_fabric"
|
|
|
|
|
2021-07-19 14:13:21 +00:00
|
|
|
echo $KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS
|
|
|
|
export XRT_TPU_CONFIG="tpu_worker;0;${KUBE_GOOGLE_CLOUD_TPU_ENDPOINTS:7}"
|
2022-10-03 13:13:33 +00:00
|
|
|
|
2022-10-04 22:54:14 +00:00
|
|
|
echo "--- Sanity check TPU availability ---"
|
2023-02-02 19:01:53 +00:00
|
|
|
python -c "import torch_xla; print(torch_xla)"
|
|
|
|
python -c "from lightning_fabric.accelerators.tpu import _XLA_AVAILABLE; print(str(_XLA_AVAILABLE))"
|
2023-01-04 15:57:18 +00:00
|
|
|
python -c "from lightning_fabric.accelerators import TPUAccelerator; assert TPUAccelerator.is_available()"
|
2022-10-04 22:54:14 +00:00
|
|
|
echo "Sanity check passed!"
|
|
|
|
|
2023-01-04 15:57:18 +00:00
|
|
|
echo "--- Running Fabric tests ---"
|
|
|
|
cd tests/tests_fabric
|
|
|
|
PL_RUN_TPU_TESTS=1 coverage run --source=lightning_fabric -m pytest -vv --durations=0 ./
|
2022-10-03 13:13:33 +00:00
|
|
|
|
2023-01-04 15:57:18 +00:00
|
|
|
echo "--- Running standalone Fabric tests ---"
|
2023-02-01 12:23:48 +00:00
|
|
|
PL_RUN_TPU_TESTS=1 PL_STANDALONE_TESTS_SOURCE=lightning_fabric PL_STANDALONE_TESTS_BATCH_SIZE=1 bash run_standalone_tests.sh
|
2022-10-03 13:13:33 +00:00
|
|
|
|
|
|
|
echo "--- Generating coverage ---"
|
2020-07-02 01:44:19 +00:00
|
|
|
coverage xml
|
|
|
|
cat coverage.xml | tr -d '\t'
|
|
|
|
|||
|
|
|
|
),
|
|
|
|
};
|
|
|
|
|
|
|
|
tputests.oneshotJob
|