From 2a3b41cbd077b229bbdd59f6f068c9b643a78b0b Mon Sep 17 00:00:00 2001 From: PyTorch MergeBot Date: Thu, 12 Jun 2025 14:42:32 +0000 Subject: [PATCH] Revert "[CI] Use `setup-python` from for Mac tests (#155698)" This reverts commit 2b9d638e3333e6e9ae324e1486774e83292e1883. Reverted https://github.com/pytorch/pytorch/pull/155698 on behalf of https://github.com/malfet due to It causes weird flaky failures in MPS and do not upload usage logs anymore ([comment](https://github.com/pytorch/pytorch/pull/155698#issuecomment-2967120676)) --- .ci/pytorch/macos-test.sh | 5 +++ .github/workflows/_mac-test.yml | 44 ++++++++++++------- ...cpp_extensions_open_device_registration.py | 4 -- test/test_multiprocessing.py | 4 -- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.ci/pytorch/macos-test.sh b/.ci/pytorch/macos-test.sh index 57549a7d63e..81bc2cd4536 100755 --- a/.ci/pytorch/macos-test.sh +++ b/.ci/pytorch/macos-test.sh @@ -5,6 +5,11 @@ set -x # shellcheck source=./macos-common.sh source "$(dirname "${BASH_SOURCE[0]}")/macos-common.sh" +if [[ -n "$CONDA_ENV" ]]; then + # Use binaries under conda environment + export PATH="$CONDA_ENV/bin":$PATH +fi + # Test that OpenMP is enabled pushd test if [[ ! $(python -c "import torch; print(int(torch.backends.openmp.is_available()))") == "1" ]]; then diff --git a/.github/workflows/_mac-test.yml b/.github/workflows/_mac-test.yml index 379801ffc40..265c3a629f4 100644 --- a/.github/workflows/_mac-test.yml +++ b/.github/workflows/_mac-test.yml @@ -60,6 +60,8 @@ jobs: test: # Don't run on forked repos or empty test matrix if: github.repository_owner == 'pytorch' && toJSON(fromJSON(inputs.test-matrix).include) != '[]' + # For setup-miniconda, see https://github.com/conda-incubator/setup-miniconda/issues/179 + # Also ensure that we always run with the right architecture defaults: run: shell: bash -e -l {0} @@ -122,8 +124,8 @@ jobs: MONITOR_LOG_INTERVAL: ${{ inputs.monitor-log-interval }} MONITOR_DATA_COLLECT_INTERVAL: ${{ inputs.monitor-data-collect-interval }} run: | - python3 -m pip install psutil==5.9.1 dataclasses_json==0.6.7 - python3 -m tools.stats.monitor --log-interval "$MONITOR_LOG_INTERVAL" --data-collect-interval "$MONITOR_DATA_COLLECT_INTERVAL" > usage_log.txt 2>&1 & + ${CONDA_RUN} python3 -m pip install psutil==5.9.1 dataclasses_json==0.6.7 + ${CONDA_RUN} python3 -m tools.stats.monitor --log-interval "$MONITOR_LOG_INTERVAL" --data-collect-interval "$MONITOR_DATA_COLLECT_INTERVAL" > usage_log.txt 2>&1 & echo "monitor-script-pid=${!}" >> "${GITHUB_OUTPUT}" - name: Download build artifacts @@ -138,10 +140,11 @@ jobs: with: use-gha: true - - name: Setup Python - uses: pytorch/test-infra/.github/actions/setup-python@main + - name: Setup miniconda + uses: pytorch/test-infra/.github/actions/setup-miniconda@main with: python-version: ${{ inputs.python-version }} + environment-file: .github/requirements/conda-env-macOS-ARM64 pip-requirements-file: .github/requirements/pip-requirements-macOS.txt default-packages: "" @@ -194,32 +197,37 @@ jobs: # shellcheck disable=SC1090 set -ex - # TODO: Remove me later, and properly activate venv - PATH="$(dirname "$(which python)"):$PATH" - export PATH + arch + + if [[ -n "$CONDA_ENV" ]]; then + # Use binaries under conda environment + export PATH="$CONDA_ENV/bin":$PATH + fi # Print out some information about the test environment - for tool in python3 python; do - which $tool - $tool --version - done + which conda + conda --version + ${CONDA_RUN} which python3 + ${CONDA_RUN} python3 --version + ${CONDA_RUN} which python + ${CONDA_RUN} python --version - python3 -mpip install --no-index --no-deps dist/*.whl + ${CONDA_RUN} python3 -mpip install --no-index --no-deps dist/*.whl set +e pushd "${RUNNER_TEMP}" # Install pip dependencies if they are not found. This is to mitigate a peculiar # flaky missing dependencies on MacOS - python3 -c "import torch" + ${CONDA_RUN} python3 -c "import torch" RC=$? popd if [ "${RC}" -ne 0 ]; then - python3 -mpip install --ignore-installed -r "${PIP_REQUIREMENTS_FILE}" + ${CONDA_RUN} python3 -mpip install --ignore-installed -r "${PIP_REQUIREMENTS_FILE}" fi set -e - .ci/pytorch/macos-test.sh + ${CONDA_RUN} .ci/pytorch/macos-test.sh - name: Print remaining test logs shell: bash @@ -231,7 +239,11 @@ jobs: shell: bash if: ${{ contains(steps.get-job-id.outputs.job-name, 'mps') }} run: | - python3 test/bench_mps_ops.py + if [[ -n "$CONDA_ENV" ]]; then + # Use binaries under conda environment + export PATH="$CONDA_ENV/bin":$PATH + fi + ${CONDA_RUN} python3 test/bench_mps_ops.py - name: Stop monitoring script diff --git a/test/test_cpp_extensions_open_device_registration.py b/test/test_cpp_extensions_open_device_registration.py index 1bde22316e2..4ec01bf6fce 100644 --- a/test/test_cpp_extensions_open_device_registration.py +++ b/test/test_cpp_extensions_open_device_registration.py @@ -74,10 +74,6 @@ class TestCppExtensionOpenRgistration(common.TestCase): torch.utils.generate_methods_for_privateuse1_backend(for_storage=True) - @unittest.skipIf( - common.IS_MACOS, - "Hangs on shutdown, see https://github.com/pytorch/pytorch/issues/155759", - ) def test_base_device_registration(self): self.assertFalse(self.module.custom_add_called()) # create a tensor using our custom device object diff --git a/test/test_multiprocessing.py b/test/test_multiprocessing.py index f855de31f7f..85c3b4d2cb3 100644 --- a/test/test_multiprocessing.py +++ b/test/test_multiprocessing.py @@ -451,10 +451,6 @@ class TestMultiprocessing(TestCase): TEST_WITH_ASAN, "seems to hang with ASAN, see https://github.com/pytorch/pytorch/issues/5326", ) - @unittest.skipIf( - IS_MACOS, - "seems to hang after completion on MacOS", - ) def test_fs_sharing(self): with fs_sharing(): # The test works but is very slow on MacOS, see https://github.com/pytorch/pytorch/pull/93183,