diff --git a/.ci/scripts/test-rocm-aoti.sh b/.ci/scripts/test-rocm-aoti.sh index 44ad516d197..2bfc84fd6c9 100644 --- a/.ci/scripts/test-rocm-aoti.sh +++ b/.ci/scripts/test-rocm-aoti.sh @@ -24,10 +24,9 @@ export TORCHINDUCTOR_COMPILE_THREADS=1 read -r TORCH_VERSION TORCHAO_VERSION < <( python - <<'PY' -from install_requirements import ROCM_TORCHAO_NIGHTLY_VERSION -from torch_pin import TORCH_VERSION +from install_requirements import ROCM_TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION -print(TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION) +print(ROCM_TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION) PY ) # TorchAO ROCm wheels are not exposed by the per-version pip index. @@ -139,7 +138,7 @@ fi export EXECUTORCH_EXECUTOR_RUNNER="${PWD}/cmake-out-rocm-llm/executor_runner" ROCM_EXCLUDED_TESTS=( - # This focused job does not install the optional flash-linear-attention package. + # This focused job does not install the optional fla-core package. --ignore=backends/cuda/tests/test_chunk_gated_delta_rule.py # Defer specialized SDPA suites until their CI cost is measured. --ignore=backends/cuda/tests/test_tq4_sdpa.py diff --git a/.ci/scripts/test-rocm-voxtral.sh b/.ci/scripts/test-rocm-voxtral.sh index a47e50a4971..bf775076c5f 100644 --- a/.ci/scripts/test-rocm-voxtral.sh +++ b/.ci/scripts/test-rocm-voxtral.sh @@ -35,10 +35,9 @@ export HF_TOKEN read -r TORCH_VERSION TORCHAO_VERSION < <( python - <<'PY' -from install_requirements import ROCM_TORCHAO_NIGHTLY_VERSION -from torch_pin import TORCH_VERSION +from install_requirements import ROCM_TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION -print(TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION) +print(ROCM_TORCH_VERSION, ROCM_TORCHAO_NIGHTLY_VERSION) PY ) # TorchAO ROCm wheels are not exposed by the per-version pip index. diff --git a/.ci/scripts/test_espressif_idf_component.sh b/.ci/scripts/test_espressif_idf_component.sh index 8dbb8babff8..82d48e831d2 100755 --- a/.ci/scripts/test_espressif_idf_component.sh +++ b/.ci/scripts/test_espressif_idf_component.sh @@ -108,9 +108,10 @@ if not any(l.startswith("generator: ") and l.endswith(" --version-suffix ''") fo sys.exit("FAIL: the release component's VERSION does not record --version-suffix ''") sys.path.insert(0, clone) from install_requirements import TORCH_URL_BASE +from torch_pin import TORCH_VERSION -if not any(re.fullmatch(r"torch_requirement: torch==\d+\.\d+\.\d+\S*", l) for l in lines): - sys.exit("FAIL: the release component's VERSION has no torch_requirement: torch==X.Y.Z") +if f"torch_requirement: torch=={TORCH_VERSION}" not in lines: + sys.exit(f"FAIL: the release component's VERSION has no torch_requirement: torch=={TORCH_VERSION}") if f"torch_index: {TORCH_URL_BASE}/cpu" not in lines: sys.exit(f"FAIL: the release component's VERSION has no torch_index: {TORCH_URL_BASE}/cpu") if f'version: "{version}"' not in (component / "idf_component.yml").read_text().splitlines(): diff --git a/.ci/scripts/tests/test_cu134_dependencies.py b/.ci/scripts/tests/test_install_dependencies.py similarity index 72% rename from .ci/scripts/tests/test_cu134_dependencies.py rename to .ci/scripts/tests/test_install_dependencies.py index c920c1d243e..96ba48a2aff 100644 --- a/.ci/scripts/tests/test_cu134_dependencies.py +++ b/.ci/scripts/tests/test_install_dependencies.py @@ -8,6 +8,7 @@ import importlib.util import io import os +import re import subprocess import sys import unittest @@ -27,7 +28,7 @@ def load_module(name): return module -class TestCu134Dependencies(unittest.TestCase): +class TestInstallDependencies(unittest.TestCase): def setUp(self): self.utils = load_module("install_utils") self.modules = patch.dict(sys.modules, {"install_utils": self.utils}) @@ -63,60 +64,40 @@ def install_commands( self.installer.install_optional_example_requirements(nightly) return [call.args[0] for call in run.call_args_list] - def test_all_install_steps_preserve_exact_cu134_selection(self): - for machine, ao_variant in (("x86_64", "cu134"), ("aarch64", "cpu")): - with self.subTest(machine=machine): - commands = self.install_commands((13, 4), machine) - self.assertEqual(len(commands), 4) - expected = { - "torch==2.15.0.dev20260921+cu134", - "torchvision==0.30.0.dev20260922+cu134", - "torchaudio==2.11.0.dev20260922+cu134", - f"torchao=={self.installer.TORCHAO_NIGHTLY_VERSION}+{ao_variant}", - } - for index, command in enumerate(commands): - required = ( - expected - if index >= 2 - else { - requirement - for requirement in expected - if requirement.startswith(("torch==", "torchao==")) - } - ) - self.assertTrue(required.issubset(command), command) - if index < 2: - self.assertFalse( - any( - arg.startswith(("torchvision", "torchaudio")) - for arg in command - ) - ) - self.assertIn( - "https://download.pytorch.org/whl/nightly/cu134", command - ) - self.assertNotIn( - "https://download.pytorch.org/whl/test/cu134", command - ) - self.assertNotIn("--no-deps", command) - if machine == "aarch64": - self.assertIn( - "https://download.pytorch.org/whl/nightly/cpu", command - ) + def assert_pins(self, core, domains, nightly=True): + if nightly: + self.assertIn(f"torch=={self.installer.TORCH_VERSION}", core) + self.assertIn(f"torchvision=={self.installer.TORCHVISION_VERSION}", domains) + self.assertIn(f"torchaudio=={self.installer.TORCHAUDIO_VERSION}", domains) + else: + self.assertIn("torch", core) + self.assertIn("torchvision", domains) + self.assertIn("torchaudio", domains) + self.assertFalse(any(arg.startswith("torch==") for arg in core)) - def test_other_cuda_trains_keep_existing_pins(self): - for cuda in ((13, 2),): + def test_cuda_trains_share_one_set_of_pins(self): + for cuda in self.utils.SUPPORTED_CUDA_VERSIONS: for machine in ("x86_64", "aarch64"): with self.subTest(cuda=cuda, machine=machine): - core, local, domains, examples = self.install_commands( - cuda, machine - ) - self.assertIn("torch==2.14.0", core) + commands = self.install_commands(cuda, machine) + self.assertEqual(len(commands), 4) + core, local, domains, examples = commands + self.assert_pins(core, domains) self.assertIn( f"torchao=={self.installer.TORCHAO_NIGHTLY_VERSION}", core ) - self.assertIn("torchvision==0.29.0", domains) - self.assertIn("torchaudio==2.11.0", domains) + train = f"cu{cuda[0]}{cuda[1]}" + self.assertIn( + f"https://download.pytorch.org/whl/test/{train}", core + ) + self.assertIn( + f"https://download.pytorch.org/whl/test/{train}", domains + ) + torchao_index = "cpu" if machine == "aarch64" else train + self.assertIn( + f"https://download.pytorch.org/whl/nightly/{torchao_index}", + core, + ) self.assertFalse(any("==" in arg for arg in local)) self.assertFalse(any("==" in arg for arg in examples)) @@ -142,47 +123,39 @@ def test_cuda_13_0_falls_back_to_cpu_with_a_warning(self): self.assertIn("CUDA 13.0 is installed but not supported", stderr.getvalue()) def test_source_pinned_torch_is_not_replaced(self): - for cuda in ((13, 2), (13, 4)): + for cuda in self.utils.SUPPORTED_CUDA_VERSIONS: with self.subTest(cuda=cuda): core, _, domains, _ = self.install_commands(cuda, nightly=False) - self.assertIn("torch", core) - self.assertNotIn("torch==2.15.0.dev20260921+cu134", core) - self.assertIn("torchvision", domains) - self.assertIn("torchaudio", domains) + self.assert_pins(core, domains, nightly=False) def test_no_cuda_keeps_default_pins(self): core, _, domains, _ = self.install_commands(None) - self.assertIn("torch==2.14.0", core) + self.assert_pins(core, domains) self.assertIn(f"torchao=={self.installer.TORCHAO_NIGHTLY_VERSION}", core) - self.assertIn("torchvision==0.29.0", domains) self.assertIn("https://download.pytorch.org/whl/test/cpu", core) def test_cpu_release_dependencies_are_opt_in(self): - for machine, python_version, audio in ( - ("x86_64", (3, 12), "2.11.0"), - ("aarch64", (3, 12), "2.11.0"), - ("x86_64", (3, 15), "2.11.1"), - ("aarch64", (3, 15), "2.11.1"), - ): - with self.subTest(machine=machine, python_version=python_version): - core, _, domains, examples = self.install_commands( - None, - machine, - python_version=python_version, - env={"EXECUTORCH_USE_RELEASE_CPU_DEPS": "1"}, - ) - self.assertIn("torch==2.14.0", core) - self.assertIn(f"torchao=={self.installer.TORCHAO_STABLE_VERSION}", core) - self.assertIn("torchvision==0.29.0", domains) - self.assertIn(f"torchaudio=={audio}", domains) - for command in (core, domains, examples): - self.assertIn("https://download.pytorch.org/whl/cpu", command) - self.assertFalse( - any("/nightly" in arg or "/test/" in arg for arg in command) + for machine in ("x86_64", "aarch64"): + for python_version in ((3, 12), (3, 15)): + with self.subTest(machine=machine, python_version=python_version): + core, _, domains, examples = self.install_commands( + None, + machine, + python_version=python_version, + env={"EXECUTORCH_USE_RELEASE_CPU_DEPS": "1"}, + ) + self.assert_pins(core, domains) + self.assertIn( + f"torchao=={self.installer.TORCHAO_STABLE_VERSION}", core ) + for command in (core, domains, examples): + self.assertIn("https://download.pytorch.org/whl/cpu", command) + self.assertFalse( + any("/nightly" in arg or "/test/" in arg for arg in command) + ) def test_cpu_release_option_keeps_cuda_pins(self): - for cuda in ((13, 2), (13, 4)): + for cuda in self.utils.SUPPORTED_CUDA_VERSIONS: for machine in ("x86_64", "aarch64"): with self.subTest(cuda=cuda, machine=machine): self.assertEqual( @@ -212,47 +185,46 @@ def test_cpu_source_build_keeps_nightly_torchao(self): self.assertIn("https://download.pytorch.org/whl/test/cpu", command) self.assertIn("third-party/ao", local) - def test_windows_does_not_select_cu134(self): + def test_windows_uses_cpu_wheels(self): core, _, domains, _ = self.install_commands((13, 4), system="Windows") - self.assertIn("torch==2.14.0", core) - self.assertIn("torchvision==0.29.0", domains) + self.assert_pins(core, domains) self.assertIn("https://download.pytorch.org/whl/test/cpu", core) - def test_python315_cpu_domains_use_available_torchaudio(self): + def test_domain_pins_do_not_depend_on_python_version(self): for system in ("Linux", "Darwin", "Windows"): - for version in ((3, 14), (3, 15)): + for version in ((3, 11), (3, 14), (3, 15)): with self.subTest(system=system, version=version): - _, _, domains, _ = self.install_commands( + core, _, domains, _ = self.install_commands( None, machine="arm64", system=system, python_version=version ) - audio = "2.11.1" if version >= (3, 15) else "2.11.0" - self.assertIn(f"torchaudio=={audio}", domains) - self.assertIn("torchvision==0.29.0", domains) + self.assert_pins(core, domains) self.assertIn("https://download.pytorch.org/whl/test/cpu", domains) - def test_python315_cuda_domains_use_available_torchaudio(self): - for machine in ("x86_64", "aarch64"): - with self.subTest(machine=machine): - _, _, domains, _ = self.install_commands( - (13, 2), machine=machine, python_version=(3, 15) + def test_rocm_scripts_install_the_rocm_torch_pin(self): + if self.installer.ROCM_TORCH_VERSION == self.installer.TORCH_VERSION: + self.skipTest( + "ROCM_TORCH_VERSION equals TORCH_VERSION, so this cannot tell " + "which pin the ROCm scripts install" + ) + for script in ("test-rocm-aoti.sh", "test-rocm-voxtral.sh"): + with self.subTest(script=script): + text = (ROOT / ".ci" / "scripts" / script).read_text() + snippet = re.search(r"python - <<'PY'\n(.*?)\nPY\n", text, re.S) + self.assertIsNotNone(snippet) + printed = subprocess.run( + [sys.executable, "-c", snippet.group(1)], + cwd=ROOT, + capture_output=True, + check=True, + text=True, + ).stdout.split() + self.assertEqual( + printed, + [ + self.installer.ROCM_TORCH_VERSION, + self.installer.ROCM_TORCHAO_NIGHTLY_VERSION, + ], ) - self.assertIn("torchaudio==2.11.1", domains) - self.assertIn("torchvision==0.29.0", domains) - self.assertIn("https://download.pytorch.org/whl/test/cu132", domains) - - def test_python315_preserves_cu134_and_source_pins(self): - for cuda in ((13, 2), (13, 4)): - for nightly in (True, False): - with self.subTest(cuda=cuda, nightly=nightly): - _, _, domains, _ = self.install_commands( - cuda, nightly=nightly, python_version=(3, 15) - ) - audio = ( - "torchaudio==2.11.0.dev20260922+cu134" - if nightly and cuda == (13, 4) - else "torchaudio==2.11.1" if nightly else "torchaudio" - ) - self.assertIn(audio, domains) def test_macos_availability_workaround_is_scoped_to_sentencepiece(self): for version in ((3, 14), (3, 15)): @@ -382,7 +354,7 @@ def test_package_install_preserves_source_pinned_torchao(self): self.assertIn("torch", core) self.assertFalse(any(arg.startswith("torch==") for arg in core)) - def test_cu134_keeps_explicit_torchao_source_build(self): + def test_explicit_torchao_source_build_is_kept(self): with patch.dict(sys.modules, {"install_requirements": self.installer}): package_installer = load_module("install_executorch") for source_flag in ( @@ -412,11 +384,20 @@ def test_cu134_keeps_explicit_torchao_source_build(self): self.assertEqual(len(commands), 5) self.assertIn("third-party/ao", commands[1]) self.assertIn(".", commands[2]) - for command in commands: - self.assertFalse( - any(arg.startswith("torchao==") for arg in command) - ) - self.assertIn("torch==2.15.0.dev20260921+cu134", commands[-1]) + self.assertIn(f"torch=={self.installer.TORCH_VERSION}", commands[0]) + self.assertIn( + f"torchao=={self.installer.TORCHAO_NIGHTLY_VERSION}", commands[0] + ) + # Nothing after the third-party/ao build may pin torchao, or pip would + # replace the source build. + self.assertFalse( + any( + arg.startswith("torchao==") + for command in commands[2:] + for arg in command + ), + commands[2:], + ) source_version = self.installer.TORCHAO_NIGHTLY_VERSION.partition( ".dev" )[0] diff --git a/.github/workflows/build-wheels-cuda-aarch64-linux.yml b/.github/workflows/build-wheels-cuda-aarch64-linux.yml index 1b8bbc9ffb5..d5cc7e97ea1 100644 --- a/.github/workflows/build-wheels-cuda-aarch64-linux.yml +++ b/.github/workflows/build-wheels-cuda-aarch64-linux.yml @@ -12,6 +12,7 @@ on: - examples/**/* - extension/cuda/**/* - install_requirements.py + - torch_pin.py - install_utils.py - pyproject.toml - setup.py diff --git a/.github/workflows/build-wheels-cuda-linux.yml b/.github/workflows/build-wheels-cuda-linux.yml index db8ecd8933f..9474d34ef86 100644 --- a/.github/workflows/build-wheels-cuda-linux.yml +++ b/.github/workflows/build-wheels-cuda-linux.yml @@ -12,6 +12,7 @@ on: - examples/**/* - extension/cuda/**/* - install_requirements.py + - torch_pin.py - install_utils.py - pyproject.toml - setup.py diff --git a/.github/workflows/build-wheels-cuda-windows.yml b/.github/workflows/build-wheels-cuda-windows.yml index 4a5887b9431..1cd9dae3da0 100644 --- a/.github/workflows/build-wheels-cuda-windows.yml +++ b/.github/workflows/build-wheels-cuda-windows.yml @@ -11,6 +11,8 @@ on: - backends/cuda/**/* - extension/cuda/**/* - install_utils.py + - install_requirements.py + - torch_pin.py - pyproject.toml - setup.py - docs/source/using-executorch-cpp.md diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index d0bc499aae9..5b679a3f156 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -627,8 +627,10 @@ jobs: popd fi - # Install flash-linear-attention for chunk_gated_delta_rule triton kernel tests - pip install "flash-linear-attention==0.4.2" + # Install FLA's kernels for the chunk_gated_delta_rule triton kernel tests and the + # Qwen3.5 tests below, which import that kernel. Releases before 0.6.0 fail to + # import under the triton 3.9 that torch 2.15 requires. + pip install -r examples/models/qwen3_5_moe/requirements.txt # Build executor_runner (needed by CUDA backend e2e tests in both shards) cmake --build cmake-out --target executor_runner diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index b655a25dddd..d4322086c52 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -958,6 +958,7 @@ jobs: contains(needs.changed-files.outputs.changed-files, 'pyproject.toml') || contains(needs.changed-files.outputs.changed-files, 'install_executorch') || contains(needs.changed-files.outputs.changed-files, 'install_requirements') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || contains(needs.changed-files.outputs.changed-files, 'install_utils.py') || contains(needs.changed-files.outputs.changed-files, 'requirements-') || contains(needs.changed-files.outputs.changed-files, 'src/executorch') || @@ -1049,6 +1050,7 @@ jobs: contains(needs.changed-files.outputs.changed-files, 'install_executorch.py') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.sh') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || contains(needs.changed-files.outputs.changed-files, 'pyproject.toml') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/_get-changed-files.yml') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/pull.yml') @@ -2172,6 +2174,7 @@ jobs: contains(needs.changed-files.outputs.changed-files, 'install_executorch.py') || contains(needs.changed-files.outputs.changed-files, 'install_executorch.sh') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.sh') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/pull.yml') || needs.run-decision.outputs.is-full-run == 'true' diff --git a/.github/workflows/test-espressif.yml b/.github/workflows/test-espressif.yml index e8c5f891ca7..be20d89f1ac 100644 --- a/.github/workflows/test-espressif.yml +++ b/.github/workflows/test-espressif.yml @@ -25,6 +25,7 @@ on: - version.txt # Read for the torch the component's VERSION and README name. - install_requirements.py + - torch_pin.py - install_utils.py # Exported by the consumer test. - examples/models/mlperf_tiny/** diff --git a/.github/workflows/test-native.yml b/.github/workflows/test-native.yml index f1ed0c682be..2325f4a46d7 100644 --- a/.github/workflows/test-native.yml +++ b/.github/workflows/test-native.yml @@ -11,6 +11,7 @@ on: - .gitmodules - CMakeLists.txt - install_requirements.py + - torch_pin.py - install_requirements.sh - requirements-dev.txt - requirements-examples.txt diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 72e82ebb339..7c6df099d82 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -731,6 +731,7 @@ jobs: contains(needs.changed-files.outputs.changed-files, '.ci/docker/ci_commit_pins/optimum-executorch.txt') || contains(needs.changed-files.outputs.changed-files, 'install_executorch.py') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/trunk.yml') || needs.run-decision.outputs.is-full-run == 'true' ) diff --git a/.github/workflows/vulkan.yml b/.github/workflows/vulkan.yml index 58873e14b05..e5ad67c019c 100644 --- a/.github/workflows/vulkan.yml +++ b/.github/workflows/vulkan.yml @@ -27,6 +27,7 @@ on: - runtime/** - schema/** - install_requirements.py + - torch_pin.py - requirements-examples.txt - setup.py - CMakeLists.txt @@ -156,6 +157,7 @@ jobs: contains(needs.changed-files.outputs.changed-files, 'runtime/') || contains(needs.changed-files.outputs.changed-files, 'schema/') || contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || contains(needs.changed-files.outputs.changed-files, 'requirements-examples.txt') || contains(needs.changed-files.outputs.changed-files, 'setup.py') || contains(needs.changed-files.outputs.changed-files, 'CMakeLists.txt') || diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml index 269f2cf2381..09658715a65 100644 --- a/.github/workflows/windows-msvc.yml +++ b/.github/workflows/windows-msvc.yml @@ -12,6 +12,8 @@ on: - .ci/docker/ci_commit_pins/pytorch.txt - .ci/scripts/** - .github/workflows/windows-msvc.yml + - torch_pin.py + - install_requirements.py workflow_dispatch: concurrency: @@ -43,6 +45,8 @@ jobs: contains(needs.changed-files.outputs.changed-files, '.ci/docker/ci_commit_pins/pytorch.txt') || contains(needs.changed-files.outputs.changed-files, '.ci/scripts/') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/windows-msvc.yml') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || + contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || needs.run-decision.outputs.is-full-run == 'true' uses: pytorch/test-infra/.github/workflows/windows_job.yml@main with: @@ -66,6 +70,8 @@ jobs: contains(needs.changed-files.outputs.changed-files, '.ci/docker/ci_commit_pins/pytorch.txt') || contains(needs.changed-files.outputs.changed-files, '.ci/scripts/') || contains(needs.changed-files.outputs.changed-files, '.github/workflows/windows-msvc.yml') || + contains(needs.changed-files.outputs.changed-files, 'torch_pin.py') || + contains(needs.changed-files.outputs.changed-files, 'install_requirements.py') || needs.run-decision.outputs.is-full-run == 'true' # test-infra's Windows setup assumes the AWS runner image; use the GitHub # hosted Windows ARM64 image directly. @@ -91,7 +97,11 @@ jobs: - name: Install build dependencies shell: pwsh - run: python -m pip install pyyaml torch==2.14.0 --extra-index-url https://download.pytorch.org/whl/test/cpu + run: | + $PSNativeCommandUseErrorActionPreference = $true + $ErrorActionPreference = 'Stop' + $torchVersion, $torchIndex = python -c "from install_requirements import TORCH_URL_BASE; from torch_pin import TORCH_VERSION; print(TORCH_VERSION); print(TORCH_URL_BASE)" + python -m pip install pyyaml "torch==$torchVersion" --extra-index-url "$torchIndex/cpu" - name: Build ExecuTorch shell: pwsh diff --git a/backends/aoti/common_shims_slim.cpp b/backends/aoti/common_shims_slim.cpp index 7217d771d01..3353940a1ad 100644 --- a/backends/aoti/common_shims_slim.cpp +++ b/backends/aoti/common_shims_slim.cpp @@ -184,6 +184,18 @@ int32_t aoti_torch_dtype_bool() { return 11; // ScalarType::Bool } +size_t aoti_torch_dtype_element_size(int32_t dtype) { + // ScalarType is int8_t-backed, so the cast truncates; scalar_type is read + // only after the range check passes. + const auto scalar_type = static_cast(dtype); + if (dtype < 0 || dtype > INT8_MAX || + !slim::c10::isValidScalarType(scalar_type)) { + ET_LOG(Error, "Unsupported dtype %d for element size", dtype); + return 0; + } + return slim::c10::elementSize(scalar_type); +} + // ============================================================ // Device Type Constants - Implementations // ============================================================ diff --git a/backends/aoti/common_shims_slim.h b/backends/aoti/common_shims_slim.h index 37cf6785c5a..29e37d13696 100644 --- a/backends/aoti/common_shims_slim.h +++ b/backends/aoti/common_shims_slim.h @@ -93,6 +93,9 @@ AOTI_SHIM_EXPORT int32_t aoti_torch_dtype_int8(); AOTI_SHIM_EXPORT int32_t aoti_torch_dtype_uint8(); AOTI_SHIM_EXPORT int32_t aoti_torch_dtype_bool(); +// Bytes per element of a dtype code, or 0 for an unsupported one. +AOTI_SHIM_EXPORT size_t aoti_torch_dtype_element_size(int32_t dtype); + // ============================================================ // Device Type Constants - Declarations // ============================================================ diff --git a/backends/aoti/tests/test_common_shims_slim.cpp b/backends/aoti/tests/test_common_shims_slim.cpp index 952a79283f2..ef0533cb433 100644 --- a/backends/aoti/tests/test_common_shims_slim.cpp +++ b/backends/aoti/tests/test_common_shims_slim.cpp @@ -707,6 +707,25 @@ TEST_F(CommonShimsSlimTest, DTypeConstants) { EXPECT_EQ(aoti_torch_dtype_bool(), 11); // ScalarType::Bool } +TEST_F(CommonShimsSlimTest, DTypeElementSize) { + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_float32()), 4); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_float64()), 8); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_bfloat16()), 2); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_float16()), 2); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_int64()), 8); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_int32()), 4); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_int16()), 2); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_int8()), 1); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_uint8()), 1); + EXPECT_EQ(aoti_torch_dtype_element_size(aoti_torch_dtype_bool()), 1); + EXPECT_EQ(aoti_torch_dtype_element_size(9), 0); // ComplexFloat + // Out of int8_t range: 262 and -250 would truncate to 6 (Float) without a + // range check. + EXPECT_EQ(aoti_torch_dtype_element_size(262), 0); + EXPECT_EQ(aoti_torch_dtype_element_size(-250), 0); + EXPECT_EQ(aoti_torch_dtype_element_size(-1), 0); // Undefined +} + // ============================================================================ // Device Type Constants Tests // ============================================================================ diff --git a/backends/aoti/tests/test_common_shims_slim_link.cpp b/backends/aoti/tests/test_common_shims_slim_link.cpp index ce60aca22de..3dc8318fa28 100644 --- a/backends/aoti/tests/test_common_shims_slim_link.cpp +++ b/backends/aoti/tests/test_common_shims_slim_link.cpp @@ -20,6 +20,7 @@ TEST(CommonShimsSlimLinkTest, ShimsAreBindableFromTheHost) { "aoti_torch_device_type_cuda", "aoti_torch_dtype_bfloat16", "aoti_torch_dtype_bool", + "aoti_torch_dtype_element_size", "aoti_torch_dtype_float16", "aoti_torch_dtype_float32", "aoti_torch_dtype_float64", diff --git a/backends/cuda/runtime/aoti_cuda_shims.lib b/backends/cuda/runtime/aoti_cuda_shims.lib index 531b8d565f6..2e7bf48ce0f 100644 Binary files a/backends/cuda/runtime/aoti_cuda_shims.lib and b/backends/cuda/runtime/aoti_cuda_shims.lib differ diff --git a/backends/cuda/runtime/aoti_cuda_shims.lib.md b/backends/cuda/runtime/aoti_cuda_shims.lib.md index 2a561c057c8..8fe72fcb60a 100644 --- a/backends/cuda/runtime/aoti_cuda_shims.lib.md +++ b/backends/cuda/runtime/aoti_cuda_shims.lib.md @@ -31,6 +31,9 @@ Then check the result is a superset of what it replaced and that no member carri timestamp, since this file ships in the wheel and a stamped one makes two builds of the same source differ. +mingw-w64 binutils 2.40 and 2.42 reproduce the checked-in file byte for byte; 2.46 +numbers the import hints from 0 instead of 1, so its output differs in every member. + A name only resolves if something in the DLL defines it. The DLL is built from the CUDA shims plus the SlimTensor common shims, so a shim added to the ETensor common shims will link and then fail to load. diff --git a/backends/cuda/tests/test_chunk_gated_delta_rule.py b/backends/cuda/tests/test_chunk_gated_delta_rule.py index 6ce177dd70a..f551419bbb5 100644 --- a/backends/cuda/tests/test_chunk_gated_delta_rule.py +++ b/backends/cuda/tests/test_chunk_gated_delta_rule.py @@ -7,7 +7,7 @@ """ Export and validate chunk_gated_delta_rule triton kernel on CUDA backend. -Requires: pip install flash-linear-attention +Requires: pip install "fla-core==0.6.0" Usage: python -m pytest backends/cuda/tests/test_chunk_gated_delta_rule.py -v @@ -44,6 +44,17 @@ B, T, H, K, V = 1, 128, 4, 64, 64 +# B > 1 exercises the flattened kernel grids, K = V = 128 is Qwen3.5's head size, +# and T = 100 leaves a partial final chunk. V = 256 with K = 64 gives several V +# blocks, and a V block count different from K's, for every BV autotune offers +# (at most 128), so a grid sized with the wrong head dimension fails. +GRID_SHAPES = [ + (2, 128, 4, 64, 64), + (1, 128, 4, 128, 128), + (2, 100, 4, 128, 128), + (2, 100, 4, 64, 256), +] + EXECUTORCH_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), "../../..")) RUNNER_PATH = os.path.join(EXECUTORCH_ROOT, "cmake-out", "executor_runner") @@ -90,8 +101,10 @@ def _make_inputs_from_fla( nonzero_h0=False, dtype=torch.bfloat16, device="cuda", + shape=(B, T, H, K, V), ): """Generate inputs following FLA test_chunk() conventions.""" + B, T, H, K, V = shape torch.manual_seed(seed) q = torch.rand(B, T, H, K, dtype=dtype, device=device) k = torch.rand(B, T, H, K, dtype=dtype, device=device) @@ -200,12 +213,20 @@ def test_eager(self): def test_eager_fla_configs(self): """Run FLA-style test configurations and verify against naive reference.""" + configs = [(c, (B, T, H, K, V)) for c in FLA_TEST_CONFIGS] + # FLA_TEST_CONFIGS[3] is nonzero_h0_norm1. + configs += [(FLA_TEST_CONFIGS[3], shape) for shape in GRID_SHAPES] + self._check_against_naive(configs) + + def _check_against_naive(self, configs): from fla.ops.gated_delta_rule.naive import naive_recurrent_gated_delta_rule model = ChunkGatedDeltaModel().eval() - for seed, norm, mask_p, nonzero_h0, desc in FLA_TEST_CONFIGS: - with self.subTest(desc=desc): - inputs = _make_inputs_from_fla(seed, norm, mask_p, nonzero_h0) + for (seed, norm, mask_p, nonzero_h0, desc), shape in configs: + with self.subTest(desc=desc, shape=shape): + inputs = _make_inputs_from_fla( + seed, norm, mask_p, nonzero_h0, shape=shape + ) q, k, v, g, beta, h0 = inputs with torch.no_grad(): diff --git a/backends/cuda/triton/kernels/chunk_gated_delta_rule.py b/backends/cuda/triton/kernels/chunk_gated_delta_rule.py index 437374457a1..efc9956fb1f 100644 --- a/backends/cuda/triton/kernels/chunk_gated_delta_rule.py +++ b/backends/cuda/triton/kernels/chunk_gated_delta_rule.py @@ -23,16 +23,32 @@ We unwrap via kernel.fn to get the inner @triton.autotune kernel and pass the heuristic-computed constexprs explicitly. -Requires: pip install flash-linear-attention +Requires: pip install "fla-core==0.6.0" """ +import importlib.metadata + import torch import triton +# Older FLA raises ValueError (not ImportError) at import under triton 3.9, which +# would break importing the whole CUDA backend; fail as ImportError first instead. +# The calls below use 0.6's private kernel signatures, so accept only 0.6.x. +try: + _FLA_VERSION = importlib.metadata.version("fla-core") +except importlib.metadata.PackageNotFoundError: + _FLA_VERSION = None +if _FLA_VERSION is None or not _FLA_VERSION.startswith("0.6."): + raise ImportError( + f"chunk_gated_delta_rule needs fla-core 0.6.0, found {_FLA_VERSION or 'none'}: " + 'pip install "fla-core==0.6.0"' + ) + from fla.ops.common.chunk_delta_h import chunk_gated_delta_rule_fwd_kernel_h_blockdim64 from fla.ops.common.chunk_o import chunk_fwd_kernel_o from fla.ops.common.chunk_scaled_dot_kkt import chunk_scaled_dot_kkt_fwd_kernel from fla.ops.gated_delta_rule.wy_fast import recompute_w_u_fwd_kernel +from fla.ops.utils.constant import RCP_LN2 from fla.ops.utils.cumsum import chunk_local_cumsum_scalar_kernel from fla.ops.utils.solve_tril import merge_16x16_to_64x64_inverse_kernel from fla.utils import IS_TMA_SUPPORTED @@ -112,22 +128,23 @@ def chunk_gated_delta_rule( NT = triton.cdiv(T, BT) scale = K**-0.5 - # 1. chunk_local_cumsum: cumulative sum of g within each chunk + # 1. chunk_local_cumsum: cumulative sum of g within each chunk, in log2 space + # because the FLA kernels below gate with exp2. g_cumsum = torch.empty(B, T, H, dtype=torch.float32, device=q.device) - wrap_triton(_unwrap(chunk_local_cumsum_scalar_kernel))[(NT, B * H)]( + wrap_triton(_unwrap(chunk_local_cumsum_scalar_kernel))[(NT * B * H,)]( s=g, o=g_cumsum, - scale=0, + scale=RCP_LN2, cu_seqlens=0, chunk_indices=0, T=T, B=B, H=H, BT=BT, - HEAD_FIRST=False, REVERSE=False, - HAS_SCALE=False, + HAS_SCALE=True, IS_VARLEN=False, + USE_GRAPH=False, ) # 2. chunk_scaled_dot_kkt: compute beta * K * K^T with gating @@ -141,6 +158,7 @@ def chunk_gated_delta_rule( chunk_indices=0, T=T, H=H, + HV=H, K=K, BT=BT, USE_G=True, @@ -177,6 +195,7 @@ def chunk_gated_delta_rule( chunk_indices=0, T=T, H=H, + HV=H, K=K, V=V, BT=BT, @@ -192,7 +211,7 @@ def chunk_gated_delta_rule( v_new = torch.empty_like(v) def grid_h(meta): - return (triton.cdiv(V, meta["BV"]), B * H) + return (triton.cdiv(V, meta["BV"]) * B * H,) wrap_triton(_unwrap(chunk_gated_delta_rule_fwd_kernel_h_blockdim64))[grid_h]( k=k, @@ -208,16 +227,16 @@ def grid_h(meta): chunk_offsets=0, T=T, H=H, + HV=H, K=K, V=V, BT=BT, - USE_EXP2=False, - TRANSPOSE_STATE=False, USE_G=True, USE_GK=False, USE_INITIAL_STATE=True, STORE_FINAL_STATE=True, SAVE_NEW_VALUE=True, + STATE_V_FIRST=False, IS_VARLEN=False, ) @@ -225,7 +244,7 @@ def grid_h(meta): o = torch.empty_like(v) def grid_o(meta): - return (triton.cdiv(V, meta["BV"]), NT, B * H) + return (triton.cdiv(V, meta["BV"]) * NT, B * H) wrap_triton(_unwrap(chunk_fwd_kernel_o))[grid_o]( q=q, @@ -240,12 +259,13 @@ def grid_o(meta): scale=scale, T=T, H=H, + HV=H, K=K, V=V, BT=BT, - TRANSPOSE_STATE=False, USE_G=True, USE_G_GAMMA=False, + STATE_V_FIRST=False, IS_VARLEN=False, ) diff --git a/examples/espressif/build_idf_component.sh b/examples/espressif/build_idf_component.sh index 1f9730bf042..913fe48bd63 100755 --- a/examples/espressif/build_idf_component.sh +++ b/examples/espressif/build_idf_component.sh @@ -129,7 +129,7 @@ COPIED_TREES=(runtime/core/portable_type/c10/c10 runtime/core/portable_type/c10/ OTHER_INPUTS=(version.txt LICENSE shim_et/xplat/executorch/build/build_variables.bzl extension/data_loader/buffer_data_loader.h extension/flat_tensor/serialize backends/cadence/aot/functions.yaml .ci/docker/ci_commit_pins/pytorch.txt examples/espressif - install_requirements.py install_utils.py) + install_requirements.py install_utils.py torch_pin.py) # Uncommitted changes to what the generator reads: to tracked files, or # untracked files where it globs, including in the flatbuffers submodule. @@ -253,15 +253,15 @@ fi # The torch that install_requirements.py installs to build ExecuTorch's wheels, # which declare none, and the CPU index it installs it from. Read before # --version exits, so a stamp check also catches a pin this cannot read. -TORCH_REQUIREMENT=$(sed -n 's/.*"\(torch==[^"]*\)" if use_pytorch_nightly.*/\1/p' \ - "$ET_ROOT/install_requirements.py") -if [ "$(printf '%s\n' "$TORCH_REQUIREMENT" | grep -c .)" != 1 ]; then - stamp_error "install_requirements.py does not name one torch==X for the wheel builds." +READ_TORCH_PIN='import sys; sys.path.insert(0, sys.argv[1]); from install_requirements import TORCH_URL_BASE, TORCH_VERSION; print(TORCH_VERSION); print(TORCH_URL_BASE)' +if ! TORCH_PIN=$("$PYTHON" -I -c "$READ_TORCH_PIN" "$ET_ROOT" 2> /dev/null); then + stamp_error "$PYTHON cannot import the torch pin from install_requirements.py: $("$PYTHON" -I -c "$READ_TORCH_PIN" "$ET_ROOT" 2>&1 | tail -n 1)" fi -READ_TORCH_URL_BASE='import sys; sys.path.insert(0, sys.argv[1]); from install_requirements import TORCH_URL_BASE; print(TORCH_URL_BASE)' -if ! TORCH_URL_BASE=$("$PYTHON" -I -c "$READ_TORCH_URL_BASE" "$ET_ROOT" 2> /dev/null); then - stamp_error "$PYTHON cannot import TORCH_URL_BASE from install_requirements.py: $("$PYTHON" -I -c "$READ_TORCH_URL_BASE" "$ET_ROOT" 2>&1 | tail -n 1)" +{ read -r TORCH_VERSION; read -r TORCH_URL_BASE; } <<< "$TORCH_PIN" +if [[ ! "$TORCH_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + stamp_error "torch_pin.py's TORCH_VERSION must be X.Y.Z, not '$TORCH_VERSION'." fi +TORCH_REQUIREMENT="torch==$TORCH_VERSION" TORCH_INDEX="$TORCH_URL_BASE/cpu" if [ "$PRINT_VERSION" = true ]; then echo "$ET_COMPONENT_VERSION" diff --git a/examples/espressif/test_version_stamp.sh b/examples/espressif/test_version_stamp.sh index dd633f52710..1a504f6a082 100755 --- a/examples/espressif/test_version_stamp.sh +++ b/examples/espressif/test_version_stamp.sh @@ -7,7 +7,7 @@ # Checks build_idf_component.sh's version stamping guards in a scratch git # repository holding only the generator, gen_kernels.py, version.txt, the -# install_requirements.py it reads the torch pin from, a FlatBuffers +# install_requirements.py and torch_pin.py it reads the torch pin from, a FlatBuffers # submodule without its sources, and a README the generator does not read. # Needs git and a Python with PyYAML, which gen_kernels.py imports. @@ -23,7 +23,8 @@ mkdir -p "${repo}/examples/espressif/idf_component_template/tools" cp "${script_dir}/idf_component_template/tools/gen_kernels.py" \ "${repo}/examples/espressif/idf_component_template/tools/" echo 1.6.0 > "${repo}/version.txt" -cp "${script_dir}/../../install_requirements.py" "${script_dir}/../../install_utils.py" "${repo}/" +cp "${script_dir}/../../install_requirements.py" "${script_dir}/../../install_utils.py" \ + "${script_dir}/../../torch_pin.py" "${repo}/" echo readme > "${repo}/README.md" export GIT_AUTHOR_NAME=test GIT_AUTHOR_EMAIL=test@example.com @@ -78,11 +79,10 @@ expect_error() { } expect_error "release stamp off a tag" "release tag" --version --version-suffix "" -pin=$(<"${repo}/install_requirements.py") -printf '%s\n' "${pin//\"torch==/\"torch>=}" > "${repo}/install_requirements.py" -expect_error "a torch pin the generator cannot read" "does not name one torch==X" \ +echo 'TORCH_VERSION = "2.15"' >> "${repo}/torch_pin.py" +expect_error "a torch pin that is not X.Y.Z" "TORCH_VERSION must be X.Y.Z" \ --version --allow-dev-stamp -git checkout -q -- install_requirements.py +git checkout -q -- torch_pin.py echo "import no_such_module" >> "${repo}/install_utils.py" expect_error "an install_requirements.py that does not import" "No module named 'no_such_module'" \ --version --allow-dev-stamp diff --git a/examples/models/qwen3_5_moe/README.md b/examples/models/qwen3_5_moe/README.md index 85c33911d1a..159811d895a 100644 --- a/examples/models/qwen3_5_moe/README.md +++ b/examples/models/qwen3_5_moe/README.md @@ -19,7 +19,8 @@ loads the `.pte`, `.ptd`, and a HuggingFace tokenizer, then generates text. - ExecuTorch installed from source (see [building from source](../../../docs/source/using-executorch-building-from-source.md)) - [safetensors](https://pypi.org/project/safetensors/) (`pip install safetensors`) - NVIDIA GPU with CUDA toolkit (tested on A100 80GB) -- Python dependencies: `pip install -r requirements.txt` (installs FLA / Flash Linear Attention) +- Python dependencies: `pip install -r requirements.txt` (installs FLA's kernels, `fla-core`) +- [transformers](https://pypi.org/project/transformers/) for `run.py`'s tokenizer; `install_executorch.sh` installs it unless run with `--minimal` - Model weights downloaded from HuggingFace. The directory should contain `config.json`, `model.safetensors.index.json`, safetensors shards, and `tokenizer.json`. diff --git a/examples/models/qwen3_5_moe/export.py b/examples/models/qwen3_5_moe/export.py index 4c060ce0137..9213a6cd28a 100644 --- a/examples/models/qwen3_5_moe/export.py +++ b/examples/models/qwen3_5_moe/export.py @@ -1315,8 +1315,9 @@ def main(): # noqa: C901 parser.error("--hqq requires --qlinear") if args.backend == "cuda": - # Register FLA Triton kernel (CUDA only) - import executorch.backends.cuda.triton.kernels # noqa: F401 + # Register FLA Triton kernel (CUDA only). Import the submodule, not the package: + # the package's __init__ silently skips it when fla-core is missing or not 0.6.x. + import executorch.backends.cuda.triton.kernels.chunk_gated_delta_rule # noqa: F401 # Reset peak GPU memory stats so we can report the actual peak # consumed during the export pipeline (load + quantize + lowering) diff --git a/examples/models/qwen3_5_moe/inference.py b/examples/models/qwen3_5_moe/inference.py index 6f9aa933535..9fc39ce7575 100644 --- a/examples/models/qwen3_5_moe/inference.py +++ b/examples/models/qwen3_5_moe/inference.py @@ -143,8 +143,9 @@ def main(): ) args = parser.parse_args() - # Register Triton kernels (fused MoE, GatedDeltaNet) - import executorch.backends.cuda.triton.kernels # noqa: F401 + # Register Triton kernels (fused MoE, GatedDeltaNet). Import the submodule, not the + # package: the package's __init__ silently skips it when fla-core is missing or not 0.6.x. + import executorch.backends.cuda.triton.kernels.chunk_gated_delta_rule # noqa: F401 # Load model print(f"Loading model from {args.prequantized}...") diff --git a/examples/models/qwen3_5_moe/requirements.txt b/examples/models/qwen3_5_moe/requirements.txt index 0c196f92d29..a602b5cdda2 100644 --- a/examples/models/qwen3_5_moe/requirements.txt +++ b/examples/models/qwen3_5_moe/requirements.txt @@ -1 +1 @@ -flash-linear-attention==0.4.2 +fla-core==0.6.0 diff --git a/examples/models/qwen3_5_moe/test_quantize_roundtrip.py b/examples/models/qwen3_5_moe/test_quantize_roundtrip.py index 430f31b3c4d..f61d3f6e6df 100644 --- a/examples/models/qwen3_5_moe/test_quantize_roundtrip.py +++ b/examples/models/qwen3_5_moe/test_quantize_roundtrip.py @@ -128,7 +128,7 @@ def _test_roundtrip(self, qlinear, qembedding, group_size, hqq=False): """Test: quantize -> save -> load_prequantized_model -> forward produces same output as quantize -> forward. """ - import executorch.backends.cuda.triton.kernels # noqa: F401 + import executorch.backends.cuda.triton.kernels.chunk_gated_delta_rule # noqa: F401 # Quantize and save bundle (before moving to CUDA, matching production flow) model_a = _make_quantized_model(qlinear, qembedding, group_size, hqq) diff --git a/examples/models/qwen3_5_moe/test_turboquant.py b/examples/models/qwen3_5_moe/test_turboquant.py index 2353dc0b8f2..6b1b2a1856d 100644 --- a/examples/models/qwen3_5_moe/test_turboquant.py +++ b/examples/models/qwen3_5_moe/test_turboquant.py @@ -56,7 +56,7 @@ def _make_model(turboquant=False): """Create a tiny quantized model, optionally with TurboQuant KV cache.""" - import executorch.backends.cuda.triton.kernels # noqa: F401 + import executorch.backends.cuda.triton.kernels.chunk_gated_delta_rule # noqa: F401 torch.manual_seed(42) model = Qwen35MoE(TINY_CONFIG) diff --git a/install_requirements.py b/install_requirements.py index ccbec9bfd6c..48e1e9a70d7 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -8,6 +8,7 @@ import argparse import os import platform +import runpy import subprocess import sys @@ -18,6 +19,11 @@ python_is_compatible, ) +# Loaded by path because setup.py executes this file without the project directory on sys.path. +TORCH_VERSION = runpy.run_path( + os.path.join(os.path.dirname(os.path.abspath(__file__)), "torch_pin.py") +)["TORCH_VERSION"] + # The pip repository that hosts nightly torch packages. # This will be dynamically set based on CUDA availability and CUDA backend enabled/disabled. TORCH_URL_BASE = "https://download.pytorch.org/whl/test" @@ -27,14 +33,12 @@ # Newest rocm7.2 TorchAO nightly with compiled kernels (cp310-abi3); later ROCm nightlies # are py3-none-any only, and none are published after 0.19.0.dev20260831. ROCM_TORCHAO_NIGHTLY_VERSION = "0.19.0.dev20260805" -# torchvision 0.30.0.dev20260922 requires exactly torch 2.15.0.dev20260921. -# download.pytorch.org keeps about 60 days of nightlies, so this pin expires; 2026-09-22 -# is the newest date whose torch, torchvision and torchaudio still all carry cp310. -CU134_TORCH_PACKAGES = [ - "torch==2.15.0.dev20260921+cu134", - "torchvision==0.30.0.dev20260922+cu134", - "torchaudio==2.11.0.dev20260922+cu134", -] +# The rocm7.2 index publishes no torch release newer than 2.14.0. +ROCM_TORCH_VERSION = "2.14.0" + +# The domain releases that go with torch_pin.py's TORCH_VERSION; bump them with it. +TORCHVISION_VERSION = "0.29.2" +TORCHAUDIO_VERSION = "2.11.1" def torchao_from_source(): @@ -61,20 +65,6 @@ def get_torch_url(): return torch_url -def cu134_requirements(torch_url, include_domains=False): - if not torch_url.endswith("/cu134"): - return [] - packages = list( - CU134_TORCH_PACKAGES if include_domains else CU134_TORCH_PACKAGES[:1] - ) - if not torchao_from_source(): - torchao_variant = ( - "cpu" if platform.machine().lower() in ("aarch64", "arm64") else "cu134" - ) - packages.append(f"torchao=={TORCHAO_NIGHTLY_VERSION}+{torchao_variant}") - return packages - - # Since ExecuTorch often uses main-branch features of pytorch, only the nightly # pip versions will have the required features. # @@ -102,11 +92,6 @@ def install_requirements(use_pytorch_nightly): # Determine the appropriate PyTorch URL based on CUDA delegate status torch_url = get_torch_url() - cu134_packages = cu134_requirements(torch_url) - if cu134_packages: - torch_url = determine_torch_url(TORCHAO_URL_BASE) - if not use_pytorch_nightly: - cu134_packages[0] = "torch" torchao_version = get_torchao_version(torch_url) if torchao_version == TORCHAO_STABLE_VERSION: torchao_url = "https://download.pytorch.org/whl/cpu" @@ -121,11 +106,11 @@ def install_requirements(use_pytorch_nightly): torchao_url = determine_torch_url(TORCHAO_URL_BASE) # pip packages needed by exir. - TORCH_PACKAGE = cu134_packages or [ + TORCH_PACKAGE = [ # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note # that we don't need to set any version number there because they have already # been installed on CI before this step, so pip won't reinstall them - ("torch==2.14.0" if use_pytorch_nightly else "torch"), + (f"torch=={TORCH_VERSION}" if use_pytorch_nightly else "torch"), f"torchao=={torchao_version}", ] @@ -197,12 +182,6 @@ def install_requirements(use_pytorch_nightly): # Without --no-build-isolation, setup.py can't find the torch module. "--no-build-isolation", *LOCAL_REQUIREMENTS, - *cu134_packages, - *( - ["--extra-index-url", torch_url, "--extra-index-url", torchao_url] - if cu134_packages - else [] - ), ], env=new_env, check=True, @@ -212,24 +191,15 @@ def install_requirements(use_pytorch_nightly): def install_optional_example_requirements(use_pytorch_nightly): # Determine the appropriate PyTorch URL based on CUDA delegate status torch_url = get_torch_url() - cu134_packages = ( - cu134_requirements(torch_url, include_domains=True) - if use_pytorch_nightly - else [] - ) - if cu134_packages: - torch_url = determine_torch_url(TORCHAO_URL_BASE) - torchao_index = ( - ["--extra-index-url", f"{TORCHAO_URL_BASE}/cpu"] - if cu134_packages and platform.machine().lower() in ("aarch64", "arm64") - else [] - ) print("Installing torch domain libraries") - torchaudio_version = "2.11.1" if sys.version_info >= (3, 15) else "2.11.0" - DOMAIN_LIBRARIES = cu134_packages or [ - ("torchvision==0.29.0" if use_pytorch_nightly else "torchvision"), - (f"torchaudio=={torchaudio_version}" if use_pytorch_nightly else "torchaudio"), + DOMAIN_LIBRARIES = [ + ( + f"torchvision=={TORCHVISION_VERSION}" + if use_pytorch_nightly + else "torchvision" + ), + (f"torchaudio=={TORCHAUDIO_VERSION}" if use_pytorch_nightly else "torchaudio"), ] # Then install domain libraries subprocess.run( @@ -241,7 +211,6 @@ def install_optional_example_requirements(use_pytorch_nightly): *DOMAIN_LIBRARIES, "--extra-index-url", torch_url, - *torchao_index, ], check=True, ) @@ -255,10 +224,8 @@ def install_optional_example_requirements(use_pytorch_nightly): "install", "-r", "requirements-examples.txt", - *cu134_packages, "--extra-index-url", torch_url, - *torchao_index, "--upgrade-strategy", "only-if-needed", ], diff --git a/torch_pin.py b/torch_pin.py index 5737d105625..175c50daf25 100644 --- a/torch_pin.py +++ b/torch_pin.py @@ -1,2 +1,2 @@ -TORCH_VERSION = "2.14.0" +TORCH_VERSION = "2.15.0" NIGHTLY_VERSION = "dev20261004"