From e65943d365f4ce79436c8fe2e30cf9187c7a9bc2 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 13:24:27 +0200 Subject: [PATCH 01/13] Try to add cibuildwheel workflow --- .github/workflows/cibuildwheel.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/cibuildwheel.yml diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml new file mode 100644 index 00000000..72d6e0d1 --- /dev/null +++ b/.github/workflows/cibuildwheel.yml @@ -0,0 +1,30 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.19.1 + env: + CIBW_SOME_OPTION: value + with: + package-dir: . + output-dir: wheelhouse + config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + From 80c7b3d2a7f7e0876d38394ccdbc6570ea541604 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 13:26:28 +0200 Subject: [PATCH 02/13] Configure cibuildwheel --- pyproject.toml | 53 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index be643e65..96bb53cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,10 +6,53 @@ requires = [ ] build-backend = "setuptools.build_meta" -# NOTE: overrides here are only used if CIBW_ENVIRONMENT is not set [tool.cibuildwheel] -environment = { PIP_CONSTRAINT="build-constraints.txt" } +build = "*" +skip = "cp36* cp37* cp38*" +test-skip = "" +free-threaded-support = false -[[tool.cibuildwheel.overrides]] -select = "*-macosx_arm64" -environment = { PIP_CONSTRAINT="build-constraints.txt", BLIS_COMPILER="clang -arch arm64" } +archs = ["auto"] +build-frontend = "default" +config-settings = {} +dependency-versions = "pinned" +environment = {} +environment-pass = [] +build-verbosity = 0 + +before-all = "" +before-build = "" +repair-wheel-command = "" + +test-command = "" +before-test = "" +test-requires = [] +test-extras = [] + +container-engine = "docker" + +manylinux-x86_64-image = "manylinux2014" +manylinux-i686-image = "manylinux2014" +manylinux-aarch64-image = "manylinux2014" +manylinux-ppc64le-image = "manylinux2014" +manylinux-s390x-image = "manylinux2014" +manylinux-pypy_x86_64-image = "manylinux2014" +manylinux-pypy_i686-image = "manylinux2014" +manylinux-pypy_aarch64-image = "manylinux2014" + +musllinux-x86_64-image = "musllinux_1_2" +musllinux-i686-image = "musllinux_1_2" +musllinux-aarch64-image = "musllinux_1_2" +musllinux-ppc64le-image = "musllinux_1_2" +musllinux-s390x-image = "musllinux_1_2" + + +[tool.cibuildwheel.linux] +repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" + +[tool.cibuildwheel.macos] +repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}" + +[tool.cibuildwheel.windows] + +[tool.cibuildwheel.pyodide] From a200d0a12636b16ab8ca74ef54ae9c83216c4599 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 13:37:00 +0200 Subject: [PATCH 03/13] Remove macos 14 --- .github/workflows/cibuildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 72d6e0d1..f5655c87 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, windows-latest, macos-13, macos-14] + os: [ubuntu-latest, windows-latest, macos-13] steps: - uses: actions/checkout@v4 From 00efec7d81cbd4d17ecf738bd90a271087b3e51d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 13:58:39 +0200 Subject: [PATCH 04/13] Fix workflow --- .github/workflows/cibuildwheel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index f5655c87..cc04bf82 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -1,6 +1,6 @@ name: Build -on: [push, pull_request] +on: [pull_request] jobs: build_wheels: From 1bd9ae06b8e0425f3fcc825cc60712494b2f49b8 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 14:20:24 +0200 Subject: [PATCH 05/13] Update cibuildwheel config --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 96bb53cc..6641f4c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,10 @@ skip = "cp36* cp37* cp38*" test-skip = "" free-threaded-support = false -archs = ["auto"] +archs_linux = ["x86_64"] +archs_macos = ["x86_64"] +archs_windows = ["AMD64"] + build-frontend = "default" config-settings = {} dependency-versions = "pinned" From 9fb243bfb972b76878a4018bea3f397f559a6a87 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 14:25:00 +0200 Subject: [PATCH 06/13] Try to fix archs commands --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6641f4c2..1d4f61e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,9 @@ skip = "cp36* cp37* cp38*" test-skip = "" free-threaded-support = false -archs_linux = ["x86_64"] -archs_macos = ["x86_64"] -archs_windows = ["AMD64"] +archs-linux = ["x86_64"] +archs-macos = ["x86_64"] +archs-windows = ["AMD64"] build-frontend = "default" config-settings = {} From 4ecbca0b04ccf268ef6c699f196efd3c7d28a01e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 14:26:54 +0200 Subject: [PATCH 07/13] Fix config --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1d4f61e4..5c993606 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,7 @@ skip = "cp36* cp37* cp38*" test-skip = "" free-threaded-support = false -archs-linux = ["x86_64"] -archs-macos = ["x86_64"] -archs-windows = ["AMD64"] +archs = ["native"] build-frontend = "default" config-settings = {} From 1d9ae753e6dcf11a3a204a529ea3e2fed1386b0a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 15:48:45 +0200 Subject: [PATCH 08/13] Skip pypy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5c993606..43bffe92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [tool.cibuildwheel] build = "*" -skip = "cp36* cp37* cp38*" +skip = "pp* cp36* cp37* cp38*" test-skip = "" free-threaded-support = false From 713fe6aa7130b17b4af6924a1f3186136e6a65a7 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 24 Jun 2024 16:29:04 +0200 Subject: [PATCH 09/13] Add another failure repro decorator --- tests/test_dotv.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/test_dotv.py b/tests/test_dotv.py index 018bc97e..0dcb5a29 100644 --- a/tests/test_dotv.py +++ b/tests/test_dotv.py @@ -1,5 +1,5 @@ from __future__ import division -from hypothesis import given, assume +from hypothesis import given, assume, reproduce_failure from math import sqrt, floor from blis_tests_common import * @@ -8,16 +8,14 @@ @given( - ndarrays(min_len=10, max_len=100, - min_val=-100.0, max_val=100.0, dtype='float64'), - ndarrays(min_len=10, max_len=100, - min_val=-100.0, max_val=100.0, dtype='float64'), + ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float64"), + ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float64"), ) def test_memoryview_double_noconj(A, B): if len(A) < len(B): - B = B[:len(A)] + B = B[: len(A)] else: - A = A[:len(B)] + A = A[: len(B)] assume(A is not None) assume(B is not None) numpy_result = A.dot(B) @@ -25,17 +23,21 @@ def test_memoryview_double_noconj(A, B): assert_allclose([numpy_result], result, atol=1e-3, rtol=1e-3) +@reproduce_failure( + "6.103.5", b"AXicY2AAggaXUAauVetzGBiBHMYGBjBgZATyGCFshhRGJgY4SGFkBmmCKmNAAgAMFQS/" +) +@reproduce_failure( + "6.103.5", b"AXicE2NAAGsxRiDJCOUpMzIipJQZWYDkQY6POYVSFz8h6WEAAGinBSs=" +) @given( - ndarrays(min_len=10, max_len=100, - min_val=-100.0, max_val=100.0, dtype='float32'), - ndarrays(min_len=10, max_len=100, - min_val=-100.0, max_val=100.0, dtype='float32'), + ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"), + ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"), ) def test_memoryview_float_noconj(A, B): if len(A) < len(B): - B = B[:len(A)] + B = B[: len(A)] else: - A = A[:len(B)] + A = A[: len(B)] assume(A is not None) assume(B is not None) numpy_result = A.dot(B) From a2ad5b7a24f68ca703ae6b5cacec6364736c3f5f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 Jul 2024 12:03:38 +0200 Subject: [PATCH 10/13] Temporarily try increasing error tolerance --- tests/test_dotv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dotv.py b/tests/test_dotv.py index 0dcb5a29..9a10a003 100644 --- a/tests/test_dotv.py +++ b/tests/test_dotv.py @@ -42,4 +42,4 @@ def test_memoryview_float_noconj(A, B): assume(B is not None) numpy_result = A.dot(B) result = dotv(A, B) - assert_allclose([numpy_result], result, atol=1e-3, rtol=1e-3) + assert_allclose([numpy_result], result, atol=1e-2, rtol=1e-2) From 2637f3f9f07eb0b2afa2c7a895ced4ae1147a469 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 Jul 2024 12:14:05 +0200 Subject: [PATCH 11/13] Try to add more debugging --- tests/test_dotv.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/test_dotv.py b/tests/test_dotv.py index 9a10a003..ea563a64 100644 --- a/tests/test_dotv.py +++ b/tests/test_dotv.py @@ -1,10 +1,9 @@ from __future__ import division -from hypothesis import given, assume, reproduce_failure -from math import sqrt, floor +from hypothesis import given, assume +import numpy from blis_tests_common import * from blis.py import dotv -from blis.cy import NO_CONJUGATE, CONJUGATE @given( @@ -23,12 +22,6 @@ def test_memoryview_double_noconj(A, B): assert_allclose([numpy_result], result, atol=1e-3, rtol=1e-3) -@reproduce_failure( - "6.103.5", b"AXicY2AAggaXUAauVetzGBiBHMYGBjBgZATyGCFshhRGJgY4SGFkBmmCKmNAAgAMFQS/" -) -@reproduce_failure( - "6.103.5", b"AXicE2NAAGsxRiDJCOUpMzIipJQZWYDkQY6POYVSFz8h6WEAAGinBSs=" -) @given( ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"), ndarrays(min_len=10, max_len=100, min_val=-100.0, max_val=100.0, dtype="float32"), @@ -42,4 +35,19 @@ def test_memoryview_float_noconj(A, B): assume(B is not None) numpy_result = A.dot(B) result = dotv(A, B) - assert_allclose([numpy_result], result, atol=1e-2, rtol=1e-2) + # We want to also know the true(r) answer, if one of them is off. + A_float64 = A.astype(numpy.float64) + B_float64 = B.astype(numpy.float64) + numpy_result64 = A_float64.dot(B_float64) + blis_result64 = dotv(A_float64, B_float64) + try: + assert_allclose( + [numpy_result], + result, + atol=1e-3, + rtol=1e-3, + ) + except AssertionError as e: + print(f"Numpy 64bit result: {numpy_result64}") + print(f"blis 64bit result: {blis_result64}") + raise e From 565a8562c3d94ecf504ecc2d65e85b6a5ddca7d9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 Jul 2024 13:48:43 +0200 Subject: [PATCH 12/13] Comment --- tests/test_dotv.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_dotv.py b/tests/test_dotv.py index ea563a64..b0b87feb 100644 --- a/tests/test_dotv.py +++ b/tests/test_dotv.py @@ -48,6 +48,7 @@ def test_memoryview_float_noconj(A, B): rtol=1e-3, ) except AssertionError as e: + # Probably better to make a combined message, but eh print(f"Numpy 64bit result: {numpy_result64}") print(f"blis 64bit result: {blis_result64}") raise e From b4e59f1ed8ebbc2b86dd3a3a7e34f2bda0b38a96 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 Jul 2024 18:37:28 +0200 Subject: [PATCH 13/13] Try to get cibuildwheel uploading to pypi --- .github/workflows/cibuildwheel.yml | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index cc04bf82..c0646bba 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -1,6 +1,9 @@ name: Build -on: [pull_request] +on: + release: + types: + - published jobs: build_wheels: @@ -28,3 +31,36 @@ jobs: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'release' && github.event.action == 'published' + # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/