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,136 +1,128 @@ 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} DISTFILES= ${PORTNAME}-${DISTVERSIONFULL}${EXTRACT_SUFX} # the main tarball disappears when GH_xx tags are added w/out this line DIST_SUBDIR= ${PORTNAME} MAINTAINER= yuri@FreeBSD.org COMMENT= PyTorch: Tensors and dynamic neural networks in Python WWW= https://pytorch.org/ \ https://github.com/pytorch/pytorch LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE BROKEN_aarch64= build fails: CMake Error at third_party/QNNPACK/CMakeLists.txt:47 (MESSAGE): Unrecognized CMAKE_SYSTEM_NAME = FreeBSD, see https://github.com/pytorch/pytorch/issues/144608 BROKEN_armv7= build fails: CMake Error at third_party/QNNPACK/CMakeLists.txt:47 (MESSAGE): Unrecognized CMAKE_SYSTEM_NAME = FreeBSD, see https://github.com/pytorch/pytorch/issues/144608 BROKEN_i386= build fails: DispatchStub.cpp:162:29: [0m[0;1;31merror: [0m[1muse of undeclared identifier 'AVX2'[0m BUILD_DEPENDS= ${PY_SETUPTOOLS} \ cmake:devel/cmake-core \ gmake:devel/gmake \ pybind11>0:devel/pybind11 \ ${PYTHON_PKGNAMEPREFIX}numpy>=1.16:math/py-numpy@${PY_FLAVOR} \ ${LOCALBASE}/include/fxdiv.h:devel/fxdiv \ ${PYTHON_PKGNAMEPREFIX}filelock>0:sysutils/py-filelock@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}fsspec>0:filesystems/py-fsspec@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}hypothesis>0:devel/py-hypothesis@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}optree>0:devel/py-optree@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}psutil>0:sysutils/py-psutil@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pyyaml>0:devel/py-pyyaml@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}sympy>=1.13.3:math/py-sympy@${PY_FLAVOR} \ ${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} \ ${PYTHON_PKGNAMEPREFIX}fsspec>0:filesystems/py-fsspec@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}Jinja2>0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}networkx>0:math/py-networkx@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}numpy>=1.16:math/py-numpy@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}sympy>=1.13.3:math/py-sympy@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}typing-extensions>=4.10.0:devel/py-typing-extensions@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pyyaml>0:devel/py-pyyaml@${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 USE_LDCONFIG= ${PYTHON_SITELIBDIR}/torch/lib # The Python package is named "torch" not "pytorch" PYDISTUTILS_PKGNAME= torch PEP517_INSTALL_CMD= ${PYTHON_CMD} -m installer --destdir ${STAGEDIR} --prefix ${PREFIX} ${BUILD_WRKSRC}/dist/torch-${DISTVERSION}*.whl USE_GITHUB= nodefault GH_TUPLE= pytorch:cpuinfo:bc3c01e:cpuinfo/cpuinfo-with-freebsd-support # https://github.com/pytorch/cpuinfo/pull/230/commits MAKE_ENV= USE_NINJA=no # ninja breaks for some reason MAKE_ENV+= BUILD_TEST=0 # ninja breaks for some reason MAKE_ENV+= USE_MKLDNN=0 # disable MKLDNN that doesn't exist, see https://github.com/pytorch/pytorch/issues/100957 MAKE_ENV+= USE_CUDNN=0 MAKE_ENV+= USE_LAPACK=1 # needed on FreeBSD to run w/out GPU MAKE_ENV+= USE_QNNPACK=0 MAKE_ENV+= USE_DISTRIBUTED=1 LDFLAGS+= -lexecinfo 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 OPTIONS_DEFINE= VULKAN OPTIONS_DEFAULT= VULKAN # VULKAN is experimental in PyTorch and only simple computations work VULKAN_MAKE_ENV= USE_VULKAN=1 USE_VULKAN_SHADERC_RUNTIME=1 USE_VULKAN_WRAPPER=0 # see https://docs.pytorch.org/tutorials/unstable/vulkan_workflow.html VULKAN_BUILD_DEPENDS= glslc:graphics/shaderc \ vulkan-headers>0:graphics/vulkan-headers VULKAN_LIB_DEPENDS= libvulkan.so:graphics/vulkan-loader .include post-patch: @cd ${WRKSRC} && \ ${RM} -r third_party/cpuinfo third_party/fbgemm/external/cpuinfo && \ ${CP} -r cpuinfo-with-freebsd-support third_party/cpuinfo && \ ${CP} -r cpuinfo-with-freebsd-support third_party/fbgemm/external/cpuinfo # change hardcoded compiler in torch/_inductor/config.py @${REINPLACE_CMD} -e 's|"g++"|"${CXX}"|' \ ${WRKSRC}/torch/_inductor/config.py do-install: # port should be moved to 'torch', but keep this for now with the hardcoded 'torch' name @${MKDIR} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} @cd ${INSTALL_WRKSRC} && ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${PEP517_INSTALL_CMD} @${PYTHON_CMD} -B ${PORTSDIR}/Mk/Scripts/strip_RECORD.py \ ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/torch-${DISTVERSION}*.dist-info/RECORD >> ${_PYTHONPKGLIST} @${REINPLACE_CMD} \ -e '/\.pyc$$/d' \ -e 's|^|${PYTHONPREFIX_SITELIBDIR}/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../etc/|etc/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../bin/|bin/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../include/|include/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../lib/|lib/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../libdata/|libdata/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../libexec/|libexec/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../man/|man/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../sbin/|sbin/|' \ -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../share/|share/|' \ ${_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 .include 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,48 +1,48 @@ ---- 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) -if(CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|x86_64)") +if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)") 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 - "Build and use Caffe2's own protobuf under third_party" ON) + "Build and use Caffe2's own protobuf under third_party" OFF) 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) -option(USE_LITE_PROTO "Use lite protobuf instead of full." OFF) +option(USE_LITE_PROTO "Use lite protobuf instead of full." ON) 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) -option(USE_SYSTEM_SLEEF "Use system-provided sleef." OFF) +option(USE_SYSTEM_SLEEF "Use system-provided sleef." ON) option(USE_SYSTEM_GLOO "Use system-provided gloo." OFF) option(USE_SYSTEM_FP16 "Use system-provided fp16." OFF) -option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." OFF) +option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." ON) option(USE_SYSTEM_PTHREADPOOL "Use system-provided pthreadpool." OFF) option(USE_SYSTEM_PSIMD "Use system-provided psimd." OFF) option(USE_SYSTEM_FXDIV "Use system-provided fxdiv." OFF) option(USE_SYSTEM_BENCHMARK "Use system-provided google benchmark." OFF) -option(USE_SYSTEM_ONNX "Use system-provided onnx." OFF) +option(USE_SYSTEM_ONNX "Use system-provided onnx." ON) option(USE_SYSTEM_XNNPACK "Use system-provided xnnpack." OFF) option(USE_SYSTEM_NVTX "Use system-provided nvtx." OFF) option(USE_GOLD_LINKER "Use ld.gold to link" 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,11 +1,11 @@ ---- 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() - if(NOT IOS AND NOT (CMAKE_SYSTEM_NAME MATCHES "^(Android|Linux|Darwin|Windows)$")) + if(NOT IOS AND NOT (CMAKE_SYSTEM_NAME MATCHES "^(Android|Linux|FreeBSD|Darwin|Windows)$")) message(WARNING "Target platform \"${CMAKE_SYSTEM_NAME}\" is not supported in {Q/X}NNPACK. " "Supported platforms are Android, iOS, Linux, and macOS. " 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,84 +1,84 @@ ---- 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 -import setuptools.command.bdist_wheel +# import setuptools.command.bdist_wheel 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") -# Need to create the proper LICENSE.txt for the wheel -class bdist_wheel(setuptools.command.bdist_wheel.bdist_wheel): - def run(self) -> None: - with concat_license_files(include_files=True): - super().run() +try: + from wheel.bdist_wheel import bdist_wheel as _bdist_wheel +except ImportError: + # This is useful when wheel is not installed and bdist_wheel is not + # specified on the command line. If it _is_ specified, parsing the command + # line will fail before bdist_wheel is needed + bdist_wheel = None +else: + # Need to create the proper LICENSE.txt for the wheel + class bdist_wheel(_bdist_wheel): + def run(self) -> None: + with concat_license_files(include_files=True): + super().run() - def write_wheelfile(self, *args: Any, **kwargs: Any) -> None: - super().write_wheelfile(*args, **kwargs) + def write_wheelfile(self, *args: Any, **kwargs: Any) -> None: + super().write_wheelfile(*args, **kwargs) - if BUILD_LIBTORCH_WHL: - if self.bdist_dir is None: - raise AssertionError("self.bdist_dir must not be None") - bdist_dir = Path(self.bdist_dir) - # Remove extraneneous files in the libtorch wheel - for file in itertools.chain( - bdist_dir.rglob("*.a"), - bdist_dir.rglob("*.so"), - ): - if (bdist_dir / file.name).is_file(): + if BUILD_LIBTORCH_WHL: + assert self.bdist_dir is not None + bdist_dir = Path(self.bdist_dir) + # Remove extraneneous files in the libtorch wheel + for file in itertools.chain( + bdist_dir.rglob("*.a"), + bdist_dir.rglob("*.so"), + ): + if (bdist_dir / file.name).is_file(): + file.unlink() + for file in bdist_dir.rglob("*.py"): file.unlink() - for file in bdist_dir.rglob("*.py"): - file.unlink() - # need an __init__.py file otherwise we wouldn't have a package - (bdist_dir / "torch" / "__init__.py").touch() + # need an __init__.py file otherwise we wouldn't have a package + (bdist_dir / "torch" / "__init__.py").touch() 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 = { - "bdist_wheel": bdist_wheel, "build_ext": build_ext, "clean": clean, "sdist": sdist, } + if bdist_wheel is not None: + cmdclass["bdist_wheel"] = bdist_wheel entry_points = { "console_scripts": [ 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,18 +1,18 @@ ---- 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"] import copy import re +import sys 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) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") def test_eager_sequence_nr(self): class Model(torch.nn.Module): def __init__(self) -> None: 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,34 +1,34 @@ ---- 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) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") 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) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") 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)) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Kineto causes SIGABRT on FreeBSD") def test_torch_profiler_use_after_with_block(self): counters.clear() 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,26 +1,26 @@ ---- 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, ) + @unittest.skipIf(sys.platform.startswith("freebsd"), "Gloo does not support FreeBSD") 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): import torch.distributed as dist 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,10 +1,10 @@ ---- 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): # Names for prologue profiling event prologue_name = "AOTDispatcher Runtime Wrapper Prologue" 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,60 +1,60 @@ ---- 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 + try: + import torchdata.datapipes # NOQA: F401 + except ImportError: + # torchdata.datapipes was removed in newer versions; skip datapipes doctests + exclude_module_list.append("torch.utils.data.datapipes.*") + # 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", ) + if sys.platform.startswith("freebsd"): + selected_tests = exclude_tests( + ["profiler/test_profiler", "dynamo/test_profiler"], + selected_tests, + "Skip profiler tests on FreeBSD (Kineto causes SIGABRT)", + ) + selected_tests = exclude_tests( + DISTRIBUTED_TESTS, + selected_tests, + "Skip distributed tests on FreeBSD (Gloo does not support FreeBSD)", + ) + selected_tests = exclude_tests( + ["test_ci_sanity_check_fail"], + selected_tests, + "Skip CI-only sanity check on FreeBSD (requires CI env var)", + ) + selected_tests = exclude_tests( + [ + "cpp_extensions/libtorch_agn_2_10_extension/test_version_compatibility", + ], + selected_tests, + "Skip g++ version-compatibility tests on FreeBSD (g++ not available)", + ) + selected_tests = exclude_tests( + ["test_vulkan"], + selected_tests, + "Skip Vulkan tests on FreeBSD (SIGSEGV in Vulkan driver teardown)", + ) + # 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", - "pytest-flakefinder", + # pytest-flakefinder is not available as a FreeBSD port; skip check "pytest-xdist", ] try: 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,43 +1,43 @@ ---- 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 + self._torchbind_test_loaded = False if not (IS_FBCODE or IS_WINDOWS or IS_MACOS): lib_file_path = find_library_location("libtorchbind_test.so") - torch.ops.load_library(str(lib_file_path)) + if lib_file_path.exists(): + torch.ops.load_library(str(lib_file_path)) + self._torchbind_test_loaded = True 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): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: 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): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: 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): - if IS_FBCODE or IS_WINDOWS or IS_MACOS: + if IS_FBCODE or IS_WINDOWS or IS_MACOS or not self._torchbind_test_loaded: self.skipTest( "torch.classes._TorchScriptTesting._ReLUClass is registered, skipping" ) 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,35 +1,35 @@ ---- 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 ) + @unittest.skipIf( + sys.platform.startswith("freebsd"), + "Hangs on FreeBSD due to profiler/JIT interaction deadlock", + ) 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') + @unittest.skipIf( + GRAPH_EXECUTOR == ProfilingMode.LEGACY, + "Hangs in legacy executor mode due to profiler/JIT interaction", + ) 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") + @unittest.skipIf( + sys.platform.startswith("freebsd"), + "Hangs on FreeBSD due to profiler/JIT interaction deadlock", + ) def test_dropout_func_requires_grad(self): def dropout_training(input): return F.dropout(input, 0.5, training=True) 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,12 +1,12 @@ ---- 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}") - torch.backends.quantized.engine = original_qe + if original_qe in qengines: + torch.backends.quantized.engine = original_qe def test_terminate_handler_on_crash(self): cmd = [sys.executable, '-c', "import os; os.environ[\"TORCH_CUSTOM_TERMINATE\"] ='1'; \ 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,13 +1,13 @@ ---- 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") + if sys.platform.startswith("freebsd"): + include_dirs.append("/usr/local/include") + libraries.append("sleef") + return include_dirs, libraries_dirs, libraries 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,11 +1,11 @@ ---- 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 -except ImportError: +except (ImportError, AttributeError): triton_version = None has_triton = False 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,26 +1,26 @@ ---- 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); - auto* child = dynamic_cast(it->get()); + auto* base = it->get(); +#if defined(__FreeBSD__) + // FreeBSD's libcxxrt uses pointer-based typeinfo comparison; dynamic_cast + // across DSO boundaries fails for template specialisations whose typeinfo + // symbol is HIDDEN (not exported). Use kind() + static_cast instead. + if (base->kind() != T::kAttrKind) { + throw IRAttributeError(name, true); + } + return static_cast(base)->value(); +#else + auto* child = dynamic_cast(base); if (child == nullptr) { throw IRAttributeError(name, true); } return child->value(); +#endif } using AVPtr = AttributeValue::Ptr; // NB: For determinism, we use a vector rather than a hash map. This does 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,13 +1,13 @@ ---- 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 + libc_name = ctypes.util.find_library("c") or "libc.so.6" + return ctypes.CDLL(libc_name) libc = get_libc() 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,11 +1,11 @@ ---- 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") + if not Path(str(lib_file_path)).exists(): + raise unittest.SkipTest(f"libtorchbind_test library not found (C++ test library not built)") torch.ops.load_library(str(lib_file_path)) 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,14 +1,14 @@ ---- 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 + import triton.language # noqa: F401 # Verify it's a real install, not a namespace pkg return True - except ImportError: + except (ImportError, AttributeError): return False