Skip to content

WIP on building wheel variants #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cc78a23
Focus CI on building a single wheel for a start
mgorny Mar 20, 2025
9890df8
trigger
mgorny Mar 20, 2025
ffd4145
disable testing for the time being
mgorny Mar 20, 2025
628cc83
Depend on variant-capable meson-python
mgorny Mar 20, 2025
264452a
Let's see if cibuildwheel can handle variant wheels
mgorny Mar 20, 2025
be6a7a8
Try disabling repair
mgorny Mar 20, 2025
d13fbfd
Try building different blas variants
mgorny Mar 20, 2025
1980f61
s/variant/variant-name/
mgorny Mar 20, 2025
806b093
Try blis instead
mgorny Mar 21, 2025
31a4731
no sudo?
mgorny Mar 21, 2025
afbb68f
gotta -y
mgorny Mar 21, 2025
3740d72
blis-devel
mgorny Mar 21, 2025
44e4677
Try building without cibw
mgorny Mar 21, 2025
6f478df
fix
mgorny Mar 21, 2025
543e303
install build
mgorny Mar 21, 2025
15a882c
enable blas variants again
mgorny Mar 21, 2025
af08dcc
back to mkl
mgorny Mar 21, 2025
5c8a36d
fix setup-args
mgorny Mar 21, 2025
a846c30
deps
mgorny Mar 21, 2025
2faaa70
sudo
mgorny Mar 21, 2025
149b0de
use pixi instead
mgorny Mar 21, 2025
92ea83f
no cache
mgorny Mar 21, 2025
e1f32b9
Switch to using -Dvariant
mgorny Mar 21, 2025
713d88f
Wire allow_noblas too
mgorny Mar 22, 2025
794c39c
Move variant processing top-level
mgorny Mar 22, 2025
e91ffc4
Support x86_64-vN variants
mgorny Mar 22, 2025
4df4695
Include x86_64 variant in job name
mgorny Mar 22, 2025
bb7ff74
Compile verbosely
mgorny Mar 22, 2025
a7a3c0e
Try setting -march
mgorny Mar 22, 2025
fe69754
Fix v1 flag
mgorny Mar 22, 2025
96e645c
fix workflow name
mgorny Mar 22, 2025
a665229
fix -march
mgorny Mar 22, 2025
4994632
fix march again
mgorny Mar 22, 2025
d00f319
Revert some irrelevant differences
mgorny Mar 26, 2025
58b9717
Disable dispatching to higher arches on non-highest target
mgorny Mar 26, 2025
3e1f2f4
Update for new x86_64 plugin
mgorny Apr 14, 2025
1e9dbc0
Use our build fork
mgorny Apr 14, 2025
8c40e2f
Add artifact upload
mgorny Apr 14, 2025
8d8cd5c
Remove redundant cflags (should be done via build-setup now)
mgorny Apr 14, 2025
f4e8007
Use pip & numpy-demo branch
mgorny Apr 14, 2025
d1f89ef
trigger build
mgorny Apr 14, 2025
d32be73
Unset CFLAGS/CXXFLAGS leaking from env
mgorny Apr 14, 2025
003e33a
Revert "Unset CFLAGS/CXXFLAGS leaking from env"
mgorny Apr 15, 2025
bd125ad
Switch to main branch of x86_64 variant plugin
mgorny Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/variant-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Workflow to build and test wheels.
# To work on the wheel building infrastructure on a fork, comment out:
#
# if: github.repository == 'numpy/numpy'
#
# in the get_commit_message job. Be sure to include [wheel build] in your commit
# message to trigger the build. All files related to wheel building are located
# at tools/wheels/
# Alternatively, you can add labels to the pull request in order to trigger wheel
# builds.
# The labels that trigger builds are:
# 36 - Build(for changes to the building process,
# 14 - Release(ensure wheels build before release)
name: Wheel builder

on:
push:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build_wheels:
name: Build wheel ${{ matrix.python }}-${{ matrix.blas }}-x86_64-${{ matrix.x86_64 }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
blas: [openblas, mkl]
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [ubuntu-22.04, manylinux_x86_64, ""]
python: ["3.12"]
x86_64: [v1, v2, v3, v4]

steps:
- name: Checkout numpy
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
persist-credentials: false

- uses: prefix-dev/[email protected]

- name: Build wheels
run: pixi run -e ${{ matrix.blas }} build -Csetup-args=-Duse-ilp64=true -Cvariant=blas::variant::${{ matrix.blas }} -Cvariant=x86_64::level::${{ matrix.x86_64 }} -Ccompile-args=-v

- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.blas }}-x86-64-${{ matrix.x86_64 }}
path: dist/*.whl
if-no-files-found: error
compression-level: 0
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,25 @@ if host_machine.system() == 'darwin' and cc.has_link_argument('-Wl,-ld_classic')
add_project_link_arguments('-Wl,-ld_classic', language : ['c', 'cpp'])
endif

blas_variant = ''
x86_64_variant = ''

foreach variant_meta : get_option('variant')
split_meta = variant_meta.split('::')
if split_meta.length() != 3
error('Invalid variant key: ' + variant_meta)
endif
if split_meta[0].strip() == 'blas' and split_meta[1].strip() == 'variant'
blas_variant = split_meta[2].strip()
elif split_meta[0].strip() == 'x86_64' and split_meta[1].strip() == 'level'
if host_machine.cpu_family() != 'x86_64'
error('Variant valid only on x86_64: ' + variant_meta)
endif
x86_64_variant = split_meta[2].strip()
else
error('Unsupported variant key: ' + variant_meta)
endif
endforeach

subdir('meson_cpu')
subdir('numpy')
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ option('test-simd', type: 'array',
description: 'Specify a list of CPU features to be tested against NumPy SIMD interface')
option('test-simd-args', type: 'string', value: '',
description: 'Extra args to be passed to the `_simd` module that is used for testing the NumPy SIMD interface')
option('variant', type: 'array', value: [],
description: 'Wheel variant keys')
17 changes: 17 additions & 0 deletions meson_cpu/x86/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
source_root = meson.project_source_root()
mod_features = import('features')

if x86_64_variant != ''
if x86_64_variant == 'v1'
CPU_CONF_BASELINE = 'min'
CPU_CONF_DISPATCH = ''
elif x86_64_variant == 'v2'
CPU_CONF_BASELINE = 'SSE42'
CPU_CONF_DISPATCH = ''
elif x86_64_variant == 'v3'
CPU_CONF_BASELINE = 'AVX2'
CPU_CONF_DISPATCH = ''
elif x86_64_variant == 'v4'
CPU_CONF_BASELINE = 'AVX512_SKX'
else
error('Unknown x86_64 variant: ' + x86_64_variant)
endif
endif

SSE = mod_features.new(
'SSE', 1, args: '-msse',
test_code: files(source_root + '/numpy/distutils/checks/cpu_sse.c')[0]
Expand Down
8 changes: 7 additions & 1 deletion numpy/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ allow_noblas = get_option('allow-noblas')
# (see cibuildwheel settings in pyproject.toml), but used by CI jobs already
blas_symbol_suffix = get_option('blas-symbol-suffix')

# Variant overrides options directly specified
if blas_variant != ''
blas_name = blas_variant
lapack_name = blas_variant
allow_noblas = false
endif

use_ilp64 = get_option('use-ilp64')
if use_ilp64
blas_interface = ['interface: ilp64']
else
blas_interface = ['interface: lp64']
endif


blas_order = get_option('blas-order')
if blas_order == ['auto']
blas_order = []
Expand Down
28 changes: 28 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[workspace]
channels = ["conda-forge"]
name = "numpy-wheel-build"
platforms = ["linux-64"]

[tasks]
build = "python -m build -w"

[dependencies]
c-compiler = "*"
cxx-compiler = "*"
fortran-compiler = "*"
pkg-config = "*"
pip = "*"
python = "*"

[pypi-dependencies]
build = { git = "https://github.com/mgorny/build", branch = "variant-deps" }

[feature.mkl.dependencies]
mkl-devel = "*"

[feature.openblas.dependencies]
openblas = "*"

[environments]
mkl = ["mkl"]
openblas = ["openblas"]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[build-system]
build-backend = "mesonpy"
requires = [
"meson-python>=0.15.0",
"meson-python @ https://github.com/mgorny/meson-python/archive/wheel-variants.tar.gz",
"Cython>=3.0.6", # keep in sync with version check in meson.build
"variant_x86_64 @ https://github.com/wheelnext/variant_x86_64/archive/main.tar.gz ; 'x86_64' in variants"
]

[project]
Expand Down
Loading