[CI] [JIT] [Build] [Bugfix] Build pybind modules against torch's bundled pybind11; drop pip pybind11 dep - #4996
[CI] [JIT] [Build] [Bugfix] Build pybind modules against torch's bundled pybind11; drop pip pybind11 dep#4996Rohan138 wants to merge 2 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
0d24e21 to
8ed622c
Compare
…pip pybind11 dep aiter's JIT builder appended the pip-installed pybind11 include path (pybind11.get_include()) as a -I ahead of torch's bundled headers, so every compiled pybind module picked up whatever pybind11 pip resolved. When pip pybind11 drifts ahead of torch (3.1.0 bumped PYBIND11_INTERNALS_VERSION 11 -> 12, released 2026-08-06), modules built at different pip epochs get different internals versions. pybind11 won't share registered types across internals versions, so a JIT module rejects the prebuilt module_aiter_core's aiter_tensor_t: TypeError: fmha_fwd_bf16_opus_fwd(): incompatible function arguments torch bundles pybind11 (3.0.1 / internals v11 in torch 2.10) at torch/include, which satisfied aiter's former pybind11>=3.0.1 requirement. Build every python module -- torch-backed and torch-free (torch_exclude, e.g. module_aiter_core) -- against those bundled headers so the aiter_tensor_t producer and its consumers always share torch's internals version, independent of any pip pybind11. torch/include is used only for header resolution here, so torch-free modules gain no runtime libtorch dependency. With the ABI sourced from torch, aiter no longer needs a pip pybind11 at all: dropped from requirements.txt, pyproject.toml build-system requires, setup.py install_requires, and the pip-install steps across CI workflows. Verified on rocm/pytorch (torch 2.10.0+rocm, bundled pybind v11) with NO pip pybind11 installed: trivial torch-backed and torch_exclude pybind modules both compile and report __pybind11_internals_v11__, and the torch_exclude .so links no libtorch/libc10. With pip pybind11==3.1.0 present, the previous code produced v12 (the mismatch) while this builds v11. Fixes #4770 Signed-off-by: Rohan Potdar <rohan.potdar@amd.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgzE8AArDkU1WcZztQfMxJ
8ed622c to
24b515a
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes pybind11 ABI incompatibilities between prebuilt and runtime-JIT’d aiter pybind modules by ensuring all pybind11 headers resolve to torch’s bundled copy (torch/include), and removes the repository’s pip pybind11 dependency accordingly.
Changes:
- Stop adding pip-installed pybind11 include paths during JIT extension builds; ensure torch/include is available for header resolution even under
torch_excludepython-module builds. - Remove
pybind11from packaging metadata (requirements.txt,pyproject.toml,setup.py) now that torch’s bundled pybind11 is the single source of headers. - Remove CI steps that explicitly install/upgrade pybind11 in downstream and test workflows.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
aiter/jit/utils/cpp_extension.py |
Ensures pybind11 headers come from torch/include for all python modules (including torch_exclude) to prevent internals-version mismatches. |
setup.py |
Drops pybind11 from install_requires. |
requirements.txt |
Drops pinned pybind11 requirement. |
pyproject.toml |
Drops pybind11 from build-system.requires. |
.github/workflows/aiter-test.yaml |
Removes CI installation/upgrade of pybind11. |
.github/workflows/atom-test.yaml |
Removes CI installation/upgrade of pybind11. |
.github/workflows/kimi-downstream.yaml |
Removes CI installation/upgrade of pybind11. |
.github/workflows/kimi-perf-downstream.yaml |
Removes CI installation/upgrade of pybind11. |
.github/workflows/vllm_benchmark.yaml |
Removes CI installation/upgrade of pybind11. |
.github/requirements/triton-test.txt |
Removes pybind11 from triton-test requirements. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The fix in this PR (using the pytorch-bundled pybind11) does tie AITER to the corresponding PyTorch version it was built with, but I assume that's already the case for now. Might need to be revisited if we want to make AITER PyTorch-stable. Also I don't know if the deps should be pinned here in the first place: https://github.com/ROCm/aiter/blob/main/requirements.txt Or at the very least, the build and install deps should be kept aligned: https://github.com/ROCm/aiter/blob/main/setup.py#L468 If the deps need to be pinned for CI/test purposes, it might be better to have a separate |
Problem
aiter's JIT builder (
aiter/jit/utils/cpp_extension.py) appends the pip-installed pybind11's include path viapybind11.get_include(), emitted as a-Iahead of torch's bundled headers (-isystem <torch>/include). So every compiled pybind module resolves#include <pybind11/...>to whatever pybind11 pip has.pybind11 3.1.0 (2026-08-06) bumped
PYBIND11_INTERNALS_VERSION11 → 12. Modules built at different pip epochs then disagree on the internals version, and pybind11 does not share registered types across internals versions. The prebuiltmodule_aiter_core(which registersaiter_tensor_t) and a JIT module built later end up incompatible:Fixes #4770.
Root cause detail
module_aiter_coreis a torch-free (torch_exclude:True) pybind module — it registersaiter_tensor_tand is loaded viactypes. It has no torch headers on its include path, so it previously took its pybind headers only from pip. Torch-backed consumer modules (e.g.fmha) also took pip's. Because they were compiled at different times, a drifting pip pybind11 desynchronized producer and consumers.Fix
torch already bundles pybind11 at
torch/include(3.0.1 / internals v11 in torch 2.10), which satisfied aiter's formerpybind11>=3.0.1. This PR builds every python module — torch-backed and torch-free — against torch's bundled pybind headers:get_include()append entirely.torch_excludebuilds (which otherwise omittorch/include), addtorch/includeback only for header resolution — pybind is header-only, so the torch-free.sogains no runtime libtorch dependency.Now producer (
module_aiter_core) and all consumers compile against the same pybind (torch's), soaiter_tensor_tstays ABI-compatible regardless of any pip pybind11. (Vendoring pybind instead would re-break this: torch-backed modules must use torch's pybind to interop with torch types, so everything has to converge on torch's copy.)With the ABI sourced from torch, aiter no longer needs a pip pybind11 dependency at all. Removed from:
requirements.txt,pyproject.toml(build-system.requires),setup.py(install_requires)pip install --upgrade pybind11steps in CI workflows (aiter-test,atom-test,kimi-downstream,kimi-perf-downstream,vllm_benchmark) and.github/requirements/triton-test.txtTest
rocm/pytorch:latest(torch 2.10.0+rocm, bundled pybind v11), with no pip pybind11 installed, building trivial pybind modules through aiter'sload():is_python_moduletorch_exclude.sointernals__pybind11_internals_v11__✅module_aiter_core)__pybind11_internals_v11__✅Both compile with zero pip pybind11 present. For contrast, with
pip install pybind11==3.1.0, the pre-change code produced__pybind11_internals_v12__(the mismatch); this change yieldsv11regardless.