|
1 | | -pip install ${PYTORCH_PIP_PREFIX} torchao --index-url ${PYTORCH_PIP_DOWNLOAD_URL} |
2 | | -# Intial smoke test, tries importing torchao |
3 | | -python ./test/smoke_tests/smoke_tests.py |
4 | | -# Now we install dev-requirments and try to run the tests |
5 | | -pip install -r dev-requirements.txt |
6 | | -pytest test --verbose -s |
| 1 | +# pip install ${PYTORCH_PIP_PREFIX} torchao --index-url ${PYTORCH_PIP_DOWNLOAD_URL} |
| 2 | +# # Intial smoke test, tries importing torchao |
| 3 | +# python ./test/smoke_tests/smoke_tests.py |
| 4 | +# # Now we install dev-requirments and try to run the tests |
| 5 | +# pip install -r dev-requirements.txt |
| 6 | +# pytest test --verbose -s |
| 7 | + |
| 8 | +# Testing compatibility |
| 9 | +# We know that torchao .so files built using PyTorch 2.8.0 are not ABI compatible with PyTorch 2.9+. (see #2919) |
| 10 | +# If the version of torch is not compatible with the version of torchao, |
| 11 | +# we expect to skip loading the .so files and a warning should be logged but no error |
| 12 | + |
| 13 | +# Function to check torchao import with configurable expectations |
| 14 | +check_torchao_import() { |
| 15 | + local expect_warning="$1" |
| 16 | + local warning_text="$2" |
| 17 | + output=$(python -c "import torchao" 2>&1) |
| 18 | + exit_code=$? |
| 19 | + |
| 20 | + if [ $exit_code -ne 0 ]; then |
| 21 | + echo "ERROR: Failed to import torchao" |
| 22 | + echo "Output: $output" |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | + |
| 26 | + warning_found=false |
| 27 | + if [ -n "$warning_text" ] && echo "$output" | grep -i "$warning_text" > /dev/null; then |
| 28 | + echo "Output: $output" |
| 29 | + warning_found=true |
| 30 | + fi |
| 31 | + |
| 32 | + if [ "$expect_warning" != "$warning_found" ]; then |
| 33 | + echo echo "FAILURE: expect_warning is $expect_warning but warning_found is $warning_found with message $output" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +} |
| 37 | + |
| 38 | +# Uninstall torch |
| 39 | +pip uninstall torch |
| 40 | +# Install compatible version of torch |
| 41 | +pip install torch==2.8.0 |
| 42 | +# Build torchao |
| 43 | +pip install torchao==0.13.0 |
| 44 | +# Test 1: Should import successfully without warning |
| 45 | +check_torchao_import "false" "" |
| 46 | + |
| 47 | +# Uninstall torch |
| 48 | +pip uninstall torch |
| 49 | +# Uninstall torchao |
| 50 | +pip uninstall torchao |
| 51 | +# Install compatible version of torch (nightly 2.9.0dev) |
| 52 | +pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu129 |
| 53 | +# Build torchao (nightly 0.14.0dev...) |
| 54 | +pip install --pre torchao --index-url https://download.pytorch.org/whl/nightly/cu129 |
| 55 | +# Test 1: Should import successfully without warning |
| 56 | +check_torchao_import "false" "" |
| 57 | + |
| 58 | +# Uninstall torch |
| 59 | +pip uninstall torch |
| 60 | +# Uninstall torchao |
| 61 | +pip uninstall torchao |
| 62 | +# Install non-ABI stable torch version with older version of torchao |
| 63 | +pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu129 |
| 64 | +# Build torchao |
| 65 | +pip install torchao==0.13.0 |
| 66 | +# Test 2: Should import with specific warning |
| 67 | +check_torchao_import "true" "Skipping import of cpp extensions due to incompatible torch version" |
0 commit comments