diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile index 1d033bd32e74..116c8e22bde7 100644 --- a/misc/py-pytorch/Makefile +++ b/misc/py-pytorch/Makefile @@ -1,7 +1,6 @@ PORTNAME= pytorch DISTVERSIONPREFIX= v -DISTVERSION= 2.11.0 -PORTREVISION= 3 +DISTVERSION= 2.12.0 CATEGORIES= misc # machine-learning MASTER_SITES= https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/ PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} @@ -39,10 +38,8 @@ BUILD_DEPENDS= ${PY_SETUPTOOLS} \ ${PYTHON_PKGNAMEPREFIX}typing-extensions>0:devel/py-typing-extensions@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} LIB_DEPENDS= libabsl_base.so:devel/abseil \ - libblis.so:math/blis \ libonnx.so:misc/onnx \ libopenblas.so:math/openblas \ - libpthreadpool.so:devel/pthreadpool \ libprotobuf.so:devel/protobuf \ libsleef.so:math/sleef RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}filelock>0:sysutils/py-filelock@${PY_FLAVOR} \ @@ -56,6 +53,8 @@ RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}filelock>0:sysutils/py-filelock@${PY_FLAVOR} RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}astunparse>0:devel/py-astunparse@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}dill>0:devel/py-dill@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}protobuf>0:devel/py-protobuf@${PY_FLAVOR} # optional dependencies +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest-rerunfailures>0:devel/py-pytest-rerunfailures@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pytest-xdist>0:devel/py-pytest-xdist@${PY_FLAVOR} USES= compiler:c++17-lang localbase:ldflags mpi:openmpi python USE_PYTHON= pep517 autoplist @@ -80,10 +79,6 @@ LDFLAGS_powerpc64le= -pthread BINARY_ALIAS= make=${GMAKE} -POST_PLIST= fix-plist - -TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest-rerunfailures>0:devel/py-pytest-rerunfailures@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}pytest-xdist>0:devel/py-pytest-xdist@${PY_FLAVOR} TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} \ TORCHINDUCTOR_CACHE_DIR=${WRKDIR}/torchinductor_cache TEST_WRKSRC= ${WRKSRC}/test @@ -127,9 +122,6 @@ do-install: # port should be moved to 'torch', but keep this for now with the ha ${_PYTHONPKGLIST} @cd ${STAGEDIR}${PREFIX} && ${FIND} lib -name '*.pyc' >> ${_PYTHONPKGLIST} -fix-plist: # remove the stray %%PYTHON_SITELIBDIR%%/caffe2 file - @${REINPLACE_CMD} -e "s|.*/caffe2$$||" ${TMPPLIST} - do-test: @cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} ${PYTHON_CMD} run_test.py diff --git a/misc/py-pytorch/distinfo b/misc/py-pytorch/distinfo index ce70ed2d40ad..9a21ad097936 100644 --- a/misc/py-pytorch/distinfo +++ b/misc/py-pytorch/distinfo @@ -1,5 +1,5 @@ -TIMESTAMP = 1776459266 -SHA256 (pytorch/pytorch-v2.11.0.tar.gz) = ab3fde9e7e382f45ac942be6ea2c2ef362c5ccd6f55ed6d5f35e6ea81d3ab88e -SIZE (pytorch/pytorch-v2.11.0.tar.gz) = 421160531 +TIMESTAMP = 1778898276 +SHA256 (pytorch/pytorch-v2.12.0.tar.gz) = 7cc1deb309f402ad67e9f45bbe311a40def4db19d66fddb9b01950f9bfc5ccb1 +SIZE (pytorch/pytorch-v2.12.0.tar.gz) = 430864016 SHA256 (pytorch/pytorch-cpuinfo-bc3c01e_GH0.tar.gz) = 09459e830a588fee730feb19d8a32fedf2d36d48db7bd9b18c3159c7e74ea0ce SIZE (pytorch/pytorch-cpuinfo-bc3c01e_GH0.tar.gz) = 3547453 diff --git a/misc/py-pytorch/files/patch-CMakeLists.txt b/misc/py-pytorch/files/patch-CMakeLists.txt index 42c8f2d0d781..4d1918b078de 100644 --- a/misc/py-pytorch/files/patch-CMakeLists.txt +++ b/misc/py-pytorch/files/patch-CMakeLists.txt @@ -1,6 +1,6 @@ ---- CMakeLists.txt.orig 2026-03-23 18:40:42 UTC +--- CMakeLists.txt.orig 2026-05-13 17:40:38 UTC +++ CMakeLists.txt -@@ -173,7 +173,7 @@ set(CPU_RISCV OFF) +@@ -184,7 +184,7 @@ set(CPU_RISCV OFF) set(CPU_POWER OFF) set(CPU_RISCV OFF) @@ -9,7 +9,7 @@ set(CPU_INTEL ON) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") set(CPU_AARCH64 ON) -@@ -205,7 +205,7 @@ option(BUILD_CUSTOM_PROTOBUF +@@ -216,7 +216,7 @@ option(BUILD_CUSTOM_PROTOBUF option(ATEN_NO_TEST "Do not build ATen test binaries" OFF) option(BUILD_BINARY "Build C++ binaries" OFF) option(BUILD_CUSTOM_PROTOBUF @@ -18,7 +18,7 @@ option(BUILD_PYTHON "Build Python binaries" ON) option(BUILD_LITE_INTERPRETER "Master flag to build Lite Interpreter" OFF) option(BUILD_SHARED_LIBS "Build libcaffe2.so" ON) -@@ -268,7 +268,7 @@ option(USE_GLOG "Use GLOG" OFF) +@@ -280,7 +280,7 @@ option(USE_GLOG "Use GLOG" OFF) option(USE_CUPTI_SO "Use CUPTI as a shared library" ON) option(USE_GFLAGS "Use GFLAGS" OFF) option(USE_GLOG "Use GLOG" OFF) @@ -27,7 +27,7 @@ option(USE_MAGMA "Use MAGMA" ON) option(USE_PYTORCH_METAL "Use Metal for PyTorch iOS build" OFF) option(USE_PYTORCH_METAL_EXPORT "Export Metal models on MacOSX desktop" OFF) -@@ -481,15 +481,15 @@ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo +@@ -496,15 +496,15 @@ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo # USE_SYSTEM_LIBS being "OFF". option(USE_SYSTEM_LIBS "Use all available system-provided libraries." OFF) option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo." OFF) diff --git a/misc/py-pytorch/files/patch-cmake_Dependencies.cmake b/misc/py-pytorch/files/patch-cmake_Dependencies.cmake index 0366113842b8..79ec9c439dec 100644 --- a/misc/py-pytorch/files/patch-cmake_Dependencies.cmake +++ b/misc/py-pytorch/files/patch-cmake_Dependencies.cmake @@ -1,6 +1,6 @@ ---- cmake/Dependencies.cmake.orig 2026-03-23 18:40:42 UTC +--- cmake/Dependencies.cmake.orig 2026-05-13 17:40:38 UTC +++ cmake/Dependencies.cmake -@@ -348,7 +348,7 @@ if(USE_NNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK) +@@ -354,7 +354,7 @@ if(USE_NNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK) set(DISABLE_NNPACK_AND_FAMILY ON) endif() else() diff --git a/misc/py-pytorch/files/patch-setup.py b/misc/py-pytorch/files/patch-setup.py index b4e96e80818d..d42417e184d8 100644 --- a/misc/py-pytorch/files/patch-setup.py +++ b/misc/py-pytorch/files/patch-setup.py @@ -1,6 +1,6 @@ ---- setup.py.orig 2026-03-23 18:40:42 UTC +--- setup.py.orig 2026-05-13 17:40:38 UTC +++ setup.py -@@ -286,7 +286,7 @@ from typing import Any, ClassVar, IO +@@ -285,7 +285,7 @@ from typing import Any, ClassVar, IO from pathlib import Path from typing import Any, ClassVar, IO @@ -9,7 +9,7 @@ import setuptools.command.build_ext import setuptools.command.sdist import setuptools.errors -@@ -1435,30 +1435,37 @@ class concat_license_files: +@@ -1425,30 +1425,37 @@ class concat_license_files: self.f1.write_text(self.bsd_text, encoding="utf-8") @@ -68,7 +68,7 @@ class clean(Command): -@@ -1647,11 +1654,12 @@ def configure_extension_build() -> tuple[ +@@ -1623,11 +1630,12 @@ def configure_extension_build() -> tuple[ ext_modules.append(C) cmdclass = { diff --git a/misc/py-pytorch/files/patch-test_dynamo_test__aot__autograd.py b/misc/py-pytorch/files/patch-test_dynamo_test__aot__autograd.py index 47c67c05b03e..3206709a1e5a 100644 --- a/misc/py-pytorch/files/patch-test_dynamo_test__aot__autograd.py +++ b/misc/py-pytorch/files/patch-test_dynamo_test__aot__autograd.py @@ -1,4 +1,4 @@ ---- test/dynamo/test_aot_autograd.py.orig 2026-04-19 12:47:58 UTC +--- test/dynamo/test_aot_autograd.py.orig 2026-05-13 17:40:38 UTC +++ test/dynamo/test_aot_autograd.py @@ -1,6 +1,7 @@ import re # Owner(s): ["module: dynamo"] @@ -8,7 +8,7 @@ import unittest from textwrap import dedent from unittest.mock import patch -@@ -1009,6 +1010,7 @@ SeqNr|OrigAten|SrcFn|FwdSrcFn +@@ -1006,6 +1007,7 @@ SeqNr|OrigAten|SrcFn|FwdSrcFn # set donated_buffer=False due to create_graph=True @torch._functorch.config.patch("donated_buffer", False) diff --git a/misc/py-pytorch/files/patch-test_dynamo_test__ctx__manager.py b/misc/py-pytorch/files/patch-test_dynamo_test__ctx__manager.py index 8320fb30997a..029f344aebed 100644 --- a/misc/py-pytorch/files/patch-test_dynamo_test__ctx__manager.py +++ b/misc/py-pytorch/files/patch-test_dynamo_test__ctx__manager.py @@ -1,6 +1,6 @@ ---- test/dynamo/test_ctx_manager.py.orig 2026-04-19 12:47:58 UTC +--- test/dynamo/test_ctx_manager.py.orig 2026-05-13 17:40:38 UTC +++ test/dynamo/test_ctx_manager.py -@@ -167,6 +167,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase +@@ -175,6 +175,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase opt_fn(a) self.assertEqual(cnts.frame_count, 2) @@ -8,7 +8,7 @@ def test_torch_profiler(self): # wrap torch.profiler.* as NullContextVariable and do nothing def fn(x): -@@ -187,6 +188,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase +@@ -195,6 +196,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase self.assertTrue(same(ref, res)) self.assertEqual(cnts.frame_count, 2) @@ -16,15 +16,15 @@ def test_autograd_profiler(self): # wrap torch.autograd.profiler.* as NullContextVariable and do nothing def fn(x): -@@ -583,6 +585,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase - res = opt_fn(x) - self.assertEqual(ref, res) +@@ -602,6 +604,7 @@ class CtxManagerTests(torch._dynamo.test_case.TestCase + self.assertRaises(torch._dynamo.exc.Unsupported, fn, args, kwargs) + self.assertEqual(torch.cuda.current_device(), initial_dev) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") def test_autograd_profiler_enabled(self): def fn(x): if torch.autograd._profiler_enabled(): -@@ -1830,6 +1833,7 @@ class GraphModule(torch.nn.Module): +@@ -2245,6 +2248,7 @@ class GraphModule(torch.nn.Module): opt_f = torch.compile(f, backend="eager") opt_f(torch.randn(2, 2)) diff --git a/misc/py-pytorch/files/patch-test_dynamo_test__guard__serialization.py b/misc/py-pytorch/files/patch-test_dynamo_test__guard__serialization.py index ba517fc6e912..c08b21f494a3 100644 --- a/misc/py-pytorch/files/patch-test_dynamo_test__guard__serialization.py +++ b/misc/py-pytorch/files/patch-test_dynamo_test__guard__serialization.py @@ -1,14 +1,14 @@ ---- test/dynamo/test_guard_serialization.py.orig 2026-04-19 12:47:58 UTC +--- test/dynamo/test_guard_serialization.py.orig 2026-05-13 17:40:38 UTC +++ test/dynamo/test_guard_serialization.py -@@ -1506,6 +1506,7 @@ class TestGuardSerialization(TestGuardSerializationBas - True, +@@ -1521,6 +1521,7 @@ class TestGuardSerialization(TestGuardSerializationBas ) + @torch._dynamo.config.patch(nested_graph_breaks=False) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Gloo does not support FreeBSD") def test_ddp_module(self): import torch.distributed as dist -@@ -1558,6 +1559,7 @@ class TestGuardSerialization(TestGuardSerializationBas +@@ -1573,6 +1574,7 @@ class TestGuardSerialization(TestGuardSerializationBas True, ) @@ -16,9 +16,9 @@ def test_unserializable_sharded_tensor(self): import torch.distributed as dist -@@ -1675,6 +1677,7 @@ class TestGuardSerialization(TestGuardSerializationBas - ref, loaded, {"inputs": Inputs(x, torch.cuda.Stream())}, True +@@ -1688,6 +1690,7 @@ class TestGuardSerialization(TestGuardSerializationBas ) + self._test_check_fn(ref, loaded, {"inputs": Inputs(x, torch.Stream())}, True) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Gloo does not support FreeBSD") def test_unused_process_group(self): diff --git a/misc/py-pytorch/files/patch-test_dynamo_test__repros.py b/misc/py-pytorch/files/patch-test_dynamo_test__repros.py index 0809cd5f470d..d2d90ed7e097 100644 --- a/misc/py-pytorch/files/patch-test_dynamo_test__repros.py +++ b/misc/py-pytorch/files/patch-test_dynamo_test__repros.py @@ -1,8 +1,8 @@ ---- test/dynamo/test_repros.py.orig 2026-04-19 12:47:58 UTC +--- test/dynamo/test_repros.py.orig 2026-05-13 17:40:38 UTC +++ test/dynamo/test_repros.py -@@ -6105,6 +6105,7 @@ def forward(self, s77 : torch.SymInt, s27 : torch.SymI - self.assertEqual(result, result_test) - self.assertEqual(x, x_test) +@@ -6252,6 +6252,7 @@ def forward(self, s77 : torch.SymInt, s27 : torch.SymI + graph_code = backend.graphs[0].print_readable(print_output=False) + self.assertIn("torch._C._nn.linear", graph_code) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") def test_aot_autograd_runtime_wrapper_prologue_profiled(self): diff --git a/misc/py-pytorch/files/patch-test_run__test.py b/misc/py-pytorch/files/patch-test_run__test.py index 8968c9b93aa7..a5c0ab2c59e5 100644 --- a/misc/py-pytorch/files/patch-test_run__test.py +++ b/misc/py-pytorch/files/patch-test_run__test.py @@ -1,6 +1,6 @@ ---- test/run_test.py.orig 2026-03-23 18:40:42 UTC +--- test/run_test.py.orig 2026-05-13 17:40:38 UTC +++ test/run_test.py -@@ -1142,6 +1142,12 @@ def run_doctests(test_module, test_directory, options) +@@ -1155,6 +1155,12 @@ def run_doctests(test_module, test_directory, options) else: enabled["onnx"] = True @@ -13,7 +13,7 @@ # Set doctest environment variables if enabled["cuda"]: os.environ["TORCH_DOCTEST_CUDA"] = "1" -@@ -1812,6 +1818,35 @@ def get_selected_tests(options) -> list[str]: +@@ -1869,6 +1875,35 @@ def get_selected_tests(options) -> list[str]: "Skip distributed tests on s390x", ) @@ -49,7 +49,7 @@ # skip all distributed tests if distributed package is not available. if not dist.is_available(): selected_tests = exclude_tests( -@@ -2086,7 +2121,7 @@ def check_pip_packages() -> None: +@@ -2148,7 +2183,7 @@ def check_pip_packages() -> None: def check_pip_packages() -> None: packages = [ "pytest-rerunfailures", diff --git a/misc/py-pytorch/files/patch-test_test__fx.py b/misc/py-pytorch/files/patch-test_test__fx.py index dc6c33660421..05c94b465f19 100644 --- a/misc/py-pytorch/files/patch-test_test__fx.py +++ b/misc/py-pytorch/files/patch-test_test__fx.py @@ -1,6 +1,6 @@ ---- test/test_fx.py.orig 2026-04-18 17:21:07 UTC +--- test/test_fx.py.orig 2026-05-13 17:40:38 UTC +++ test/test_fx.py -@@ -248,9 +248,12 @@ class TestFX(JitTestCase): +@@ -252,9 +252,12 @@ class TestFX(JitTestCase): ) torch.fx.proxy.TracerBase.check_mutable_operations = True @@ -14,7 +14,7 @@ def tearDown(self): super().tearDown() -@@ -869,7 +872,7 @@ class TestFX(JitTestCase): +@@ -873,7 +876,7 @@ class TestFX(JitTestCase): self.checkGraphModule(m, (a, b)) def test_native_callable(self): @@ -23,7 +23,7 @@ raise unittest.SkipTest("non-portable load_library call used in test") # This test exercises the case where we use FX to translate from Python # code to some native callable object -@@ -3062,7 +3065,7 @@ class TestFX(JitTestCase): +@@ -3067,7 +3070,7 @@ class TestFX(JitTestCase): node.__update_args_kwargs((), {}) def test_torchbind_class_attribute_in_fx(self): @@ -32,7 +32,7 @@ self.skipTest( "torch.classes._TorchScriptTesting._StackString is registered, skipping" ) -@@ -3079,7 +3082,7 @@ class TestFX(JitTestCase): +@@ -3084,7 +3087,7 @@ class TestFX(JitTestCase): self.checkGraphModule(m, ()) def test_torchbind_class_attribute_in_fx_tensor_arg(self): diff --git a/misc/py-pytorch/files/patch-test_test__jit.py b/misc/py-pytorch/files/patch-test_test__jit.py index ccb3b8585f70..d99547eafc8e 100644 --- a/misc/py-pytorch/files/patch-test_test__jit.py +++ b/misc/py-pytorch/files/patch-test_test__jit.py @@ -1,6 +1,6 @@ ---- test/test_jit.py.orig 2026-04-18 22:16:10 UTC +--- test/test_jit.py.orig 2026-05-13 17:40:38 UTC +++ test/test_jit.py -@@ -375,6 +375,10 @@ class TestJitProfiler(JitTestCase): +@@ -377,6 +377,10 @@ class TestJitProfiler(JitTestCase): self.graph_executor_optimize_opt ) @@ -11,7 +11,7 @@ def test_profiler(self): torch._C._set_graph_executor_optimize(False) -@@ -1832,6 +1836,10 @@ graph(%Ra, %Rb): +@@ -1838,6 +1842,10 @@ graph(%Ra, %Rb): @slowTest @unittest.skipIf(GRAPH_EXECUTOR != ProfilingMode.LEGACY, 'Testing differentiable graph') @@ -22,7 +22,7 @@ def test_dropout_module_requires_grad(self): with enable_profiling_mode_for_profiling_tests(): class MyModule(torch.nn.Module): -@@ -1875,6 +1883,10 @@ graph(%Ra, %Rb): +@@ -1881,6 +1889,10 @@ graph(%Ra, %Rb): @unittest.skipIf(GRAPH_EXECUTOR == ProfilingMode.SIMPLE, 'Testing differentiable graph') @skipIfTorchDynamo("Torchdynamo cannot correctly handle profiler.profile calls") diff --git a/misc/py-pytorch/files/patch-test_test__torch.py b/misc/py-pytorch/files/patch-test_test__torch.py index 208fbbcbe079..2b3c5384ade6 100644 --- a/misc/py-pytorch/files/patch-test_test__torch.py +++ b/misc/py-pytorch/files/patch-test_test__torch.py @@ -1,6 +1,6 @@ ---- test/test_torch.py.orig 2026-04-19 01:42:54 UTC +--- test/test_torch.py.orig 2026-05-13 17:40:38 UTC +++ test/test_torch.py -@@ -9464,7 +9464,8 @@ tensor([[[1.+1.j, 1.+1.j, 1.+1.j, ..., 1.+1.j, 1.+1.j +@@ -9538,7 +9538,8 @@ tensor([[[1.+1.j, 1.+1.j, 1.+1.j, ..., 1.+1.j, 1.+1.j torch.backends.quantized.engine = qe if torch.backends.quantized.engine != qe: raise AssertionError(f"qengine not set successfully: expected {qe}, got {torch.backends.quantized.engine}") diff --git a/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ConfigLoader.cpp b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ConfigLoader.cpp new file mode 100644 index 000000000000..0535999a9c3c --- /dev/null +++ b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ConfigLoader.cpp @@ -0,0 +1,35 @@ +-- Guard hasOriginalSignalHandler() and handle_signal() with #ifdef __linux__ so they +-- are not defined on non-Linux platforms where they are never called; the previous code +-- defined them unconditionally, causing -Wunused-function errors on FreeBSD with Clang. +--- third_party/kineto/libkineto/src/ConfigLoader.cpp.orig 2026-05-16 03:52:38 UTC ++++ third_party/kineto/libkineto/src/ConfigLoader.cpp +@@ -46,17 +46,13 @@ static struct sigaction originalUsr2Handler = {}; + // Look for an on-demand config file. + // If none is found, default to base config. + // Try to not affect existing handlers +-static bool hasOriginalSignalHandler() { + #ifdef __linux__ ++static bool hasOriginalSignalHandler() { + return originalUsr2Handler.sa_handler != nullptr || + originalUsr2Handler.sa_sigaction != nullptr; +-#else +- return false; +-#endif + } + +-static void handle_signal([[maybe_unused]] int signal) { +-#ifdef __linux__ ++static void handle_signal(int signal) { + if (signal == SIGUSR2) { + ConfigLoader::instance().handleOnDemandSignal(); + if (hasOriginalSignalHandler()) { +@@ -67,8 +63,8 @@ static void handle_signal([[maybe_unused]] int signal) + sigaction(SIGUSR2, &act, &originalUsr2Handler); + } + } +-#endif + } ++#endif + + static void setupSignalHandler([[maybe_unused]] bool enableSigUsr2) { + #ifdef __linux__ diff --git a/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_Logger.h b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_Logger.h new file mode 100644 index 000000000000..75644e20d6ae --- /dev/null +++ b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_Logger.h @@ -0,0 +1,13 @@ +-- Mark errnum_ with [[maybe_unused]] because it is only read inside #ifdef __linux__ +-- code; Clang emits -Wunused-private-field on FreeBSD without this annotation. +--- third_party/kineto/libkineto/src/Logger.h.orig 2026-05-16 03:52:38 UTC ++++ third_party/kineto/libkineto/src/Logger.h +@@ -134,7 +134,7 @@ class Logger { + private: + std::stringstream buf_; + std::ostream& out_; +- int errnum_; ++ [[maybe_unused]] int errnum_; + int messageSeverity_; + static std::atomic_int severityLevel_; + static std::atomic_int verboseLogLevel_; diff --git a/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp new file mode 100644 index 000000000000..3774df343db5 --- /dev/null +++ b/misc/py-pytorch/files/patch-third__party_kineto_libkineto_src_ThreadUtil.cpp @@ -0,0 +1,18 @@ +-- Guard basename() with #ifdef __linux__ since it is only called from Linux-specific +-- code; without the guard Clang emits -Wunneeded-internal-declaration treated as error. +--- third_party/kineto/libkineto/src/ThreadUtil.cpp.orig 2026-05-16 03:52:38 UTC ++++ third_party/kineto/libkineto/src/ThreadUtil.cpp +@@ -130,11 +130,13 @@ constexpr size_t kMaxThreadNameLength = 16; + namespace { + constexpr size_t kMaxThreadNameLength = 16; + ++#ifdef __linux__ + constexpr const char* basename(const char* s, int off = 0) { + return !s[off] ? s + : s[off] == '/' ? basename(&s[off + 1]) + : basename(s, off + 1); + } ++#endif + #if defined(_WIN32) + void* getKernel32Func(const char* procName) { + return reinterpret_cast( diff --git a/misc/py-pytorch/files/patch-torch___inductor_cpp__builder.py b/misc/py-pytorch/files/patch-torch___inductor_cpp__builder.py index 7ac2d5428b6b..d7f46c1512af 100644 --- a/misc/py-pytorch/files/patch-torch___inductor_cpp__builder.py +++ b/misc/py-pytorch/files/patch-torch___inductor_cpp__builder.py @@ -1,6 +1,6 @@ ---- torch/_inductor/cpp_builder.py.orig 2026-04-18 06:34:35 UTC +--- torch/_inductor/cpp_builder.py.orig 2026-05-13 17:40:44 UTC +++ torch/_inductor/cpp_builder.py -@@ -1185,6 +1185,10 @@ def _get_torch_related_args( +@@ -1253,6 +1253,10 @@ def _get_torch_related_args( if _IS_WINDOWS: libraries.append("sleef") diff --git a/misc/py-pytorch/files/patch-torch___inductor_ir.py b/misc/py-pytorch/files/patch-torch___inductor_ir.py index f92c7880bb61..bfa772398583 100644 --- a/misc/py-pytorch/files/patch-torch___inductor_ir.py +++ b/misc/py-pytorch/files/patch-torch___inductor_ir.py @@ -1,6 +1,6 @@ ---- torch/_inductor/ir.py.orig 2026-04-19 02:49:11 UTC +--- torch/_inductor/ir.py.orig 2026-05-13 17:40:44 UTC +++ torch/_inductor/ir.py -@@ -133,7 +133,7 @@ try: +@@ -137,7 +137,7 @@ try: triton_version = triton.__version__ has_triton = True diff --git a/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_init.cpp b/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_init.cpp deleted file mode 100644 index 3e479bf2fb93..000000000000 --- a/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_init.cpp +++ /dev/null @@ -1,11 +0,0 @@ ---- torch/csrc/distributed/c10d/init.cpp.orig 2026-04-17 22:57:32 UTC -+++ torch/csrc/distributed/c10d/init.cpp -@@ -887,7 +887,7 @@ This class does not support ``__members__`` property.) - return ::c10d::ReduceOp(self); - }) - .def(py::pickle( -- [](const ::c10d::ReduceOp& r) { -+ [](const ::c10d::ReduceOp& r) -> py::tuple { - // __getstate__ - if (r.op_ != ::c10d::ReduceOp::RedOpType::PREMUL_SUM) { - return py::make_tuple(r.op_, py::none()); diff --git a/misc/py-pytorch/files/patch-torch_csrc_jit_ir_ir.h b/misc/py-pytorch/files/patch-torch_csrc_jit_ir_ir.h index 624e3c52dbc2..536b62cb6522 100644 --- a/misc/py-pytorch/files/patch-torch_csrc_jit_ir_ir.h +++ b/misc/py-pytorch/files/patch-torch_csrc_jit_ir_ir.h @@ -1,6 +1,6 @@ ---- torch/csrc/jit/ir/ir.h.orig 2026-04-18 03:53:37 UTC +--- torch/csrc/jit/ir/ir.h.orig 2026-05-13 17:40:44 UTC +++ torch/csrc/jit/ir/ir.h -@@ -943,11 +943,22 @@ struct TORCH_API Node { +@@ -935,11 +935,22 @@ struct TORCH_API Node { typename T::ValueType& getAttr(Symbol name) const { AT_ASSERT(name.is_attr()); auto it = findAttr(name, true); diff --git a/misc/py-pytorch/files/patch-torch_csrc_jit_python_init.cpp b/misc/py-pytorch/files/patch-torch_csrc_jit_python_init.cpp deleted file mode 100644 index 13a3e60871c8..000000000000 --- a/misc/py-pytorch/files/patch-torch_csrc_jit_python_init.cpp +++ /dev/null @@ -1,20 +0,0 @@ ---- torch/csrc/jit/python/init.cpp.orig 2026-04-17 22:48:51 UTC -+++ torch/csrc/jit/python/init.cpp -@@ -1796,7 +1796,7 @@ void initJITBindings(PyObject* module) { - - m.def( - "_jit_get_operation", -- [](const std::string& op_name) { -+ [](const std::string& op_name) -> py::tuple { - try { - auto symbol = Symbol::fromQualString(op_name); - const auto sortedOps = getAllSortedOperatorsFor(symbol); -@@ -1843,7 +1843,7 @@ void initJITBindings(PyObject* module) { - "_maybe_call_torch_function_for_op_packet", - [](py::handle op_overload_packet, - const py::args& args, -- const py::kwargs& kwargs) { -+ const py::kwargs& kwargs) -> py::tuple { - py::list ns_method = - op_overload_packet.attr("_qualified_op_name").attr("split")("::"); - auto res = _maybe_handle_torch_function( diff --git a/misc/py-pytorch/files/patch-torch_csrc_utils_python__arg__parser.cpp b/misc/py-pytorch/files/patch-torch_csrc_utils_python__arg__parser.cpp deleted file mode 100644 index 9ca1521de078..000000000000 --- a/misc/py-pytorch/files/patch-torch_csrc_utils_python__arg__parser.cpp +++ /dev/null @@ -1,17 +0,0 @@ ---- torch/csrc/utils/python_arg_parser.cpp.orig 2026-04-17 22:45:38 UTC -+++ torch/csrc/utils/python_arg_parser.cpp -@@ -755,9 +755,11 @@ auto handle_torch_function_indexing( - } - py::object func = - PyObject_FastGetAttrString(THPVariableClass, (char*)func_name); -- py::object args = (val == nullptr) -- ? py::make_tuple(py::handle(self), py::handle(index)) -- : py::make_tuple(py::handle(self), py::handle(index), py::handle(val)); -+ py::tuple args; -+ if (val == nullptr) -+ args = py::make_tuple(py::handle(self), py::handle(index)); -+ else -+ args = py::make_tuple(py::handle(self), py::handle(index), py::handle(val)); - return handle_torch_function_no_python_arg_parser( - overridable_args, - args.ptr(), diff --git a/misc/py-pytorch/files/patch-torch_distributed_elastic_multiprocessing_redirects.py b/misc/py-pytorch/files/patch-torch_distributed_elastic_multiprocessing_redirects.py index 7982c51cfd73..85211e49a850 100644 --- a/misc/py-pytorch/files/patch-torch_distributed_elastic_multiprocessing_redirects.py +++ b/misc/py-pytorch/files/patch-torch_distributed_elastic_multiprocessing_redirects.py @@ -1,8 +1,8 @@ ---- torch/distributed/elastic/multiprocessing/redirects.py.orig 2026-04-19 02:32:30 UTC +--- torch/distributed/elastic/multiprocessing/redirects.py.orig 2026-05-13 17:40:44 UTC +++ torch/distributed/elastic/multiprocessing/redirects.py -@@ -31,7 +31,9 @@ def get_libc(): +@@ -47,7 +47,9 @@ def get_libc(): + "msvcr110, msvcr100). Redirects cannot function without a CRT." ) - return None else: - return ctypes.CDLL("libc.so.6") + import ctypes.util diff --git a/misc/py-pytorch/files/patch-torch_testing___internal_torchbind__impls.py b/misc/py-pytorch/files/patch-torch_testing___internal_torchbind__impls.py index 89cba82e6514..bbcb0ae9709e 100644 --- a/misc/py-pytorch/files/patch-torch_testing___internal_torchbind__impls.py +++ b/misc/py-pytorch/files/patch-torch_testing___internal_torchbind__impls.py @@ -1,6 +1,6 @@ ---- torch/testing/_internal/torchbind_impls.py.orig 2026-04-18 20:48:50 UTC +--- torch/testing/_internal/torchbind_impls.py.orig 2026-05-13 17:40:45 UTC +++ torch/testing/_internal/torchbind_impls.py -@@ -181,6 +181,8 @@ def load_torchbind_test_lib(): +@@ -180,6 +180,8 @@ def load_torchbind_test_lib(): lib_file_path = find_library_location("torchbind_test.dll") else: lib_file_path = find_library_location("libtorchbind_test.so") diff --git a/misc/py-pytorch/files/patch-torch_utils___triton.py b/misc/py-pytorch/files/patch-torch_utils___triton.py index 09b0ac6b8cd4..9402ba89fb04 100644 --- a/misc/py-pytorch/files/patch-torch_utils___triton.py +++ b/misc/py-pytorch/files/patch-torch_utils___triton.py @@ -1,6 +1,6 @@ ---- torch/utils/_triton.py.orig 2026-04-19 02:46:16 UTC +--- torch/utils/_triton.py.orig 2026-05-13 17:40:45 UTC +++ torch/utils/_triton.py -@@ -7,9 +7,10 @@ def has_triton_package() -> bool: +@@ -8,9 +8,10 @@ def has_triton_package() -> bool: def has_triton_package() -> bool: try: import triton # noqa: F401