Skip to content

fix: protect dependency headers and align stable ABI versions - #96

Merged
yeahdongcn merged 6 commits into
MooreThreads:mainfrom
WindDaoist:fix/protect-dependency-porting
Aug 3, 2026
Merged

fix: protect dependency headers and align stable ABI versions#96
yeahdongcn merged 6 commits into
MooreThreads:mainfrom
WindDaoist:fix/protect-dependency-porting

Conversation

@WindDaoist

@WindDaoist WindDaoist commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep dependency include paths available to the compiler while excluding configured dependency roots from in-place CUDA-to-MUSA porting.
  • Add TORCHADA_EXCLUDE_DIRS, accepting paths or complete directory names such as torch_musa; explicitly supplied source directories remain portable.
  • Select stable-ABI compatibility from the installed torch version: torch 2.9 uses torchada's header backport for MUSA extension builds, while torch 2.11 and newer use the native stable ABI without patching installed headers.
  • Align the stable MUSA stream and BLAS-handle shims and mappings across the torch 2.9 compatibility path and the torch 2.11 native path.
  • Extend the existing end-to-end stable-ABI pytest with vLLM's weak_ref_tensor surface and version-specific backport/native assertions.

Motivation

Editable dependencies such as /home/torch_musa can appear in downstream extension include paths. TORCHADA_EXCLUDE_DIRS=torch_musa keeps those dependency headers available for compilation without treating the checkout as a SimplePorting source root.

The stable header backport is required by the supported torch 2.9 line. Torch 2.11 provides the stable ABI natively, so torchada detects torch.__version__ and skips the on-disk header backport on torch 2.11 and newer. The build remains automatic for downstream extensions; no per-extension opt-in is introduced.

Tests

Targeted unit coverage:

51 passed, 1 skipped, 204 deselected
PYTHONPATH=src python -m pytest -q \
  tests/test_cpp_extension.py \
  tests/test_inplace_porting.py \
  tests/test_cuda_patching.py \
  -k 'stable or dependency or inplace' \
  tests/test_stable_abi_mappings.py

End-to-end stable-ABI matrix on one MTT S5000 with MUSA driver/runtime 5.2.0:

torch 2.9.1.post1+musa5.2.0
torch_musa 2.9.1.post1+musa5.2.0
test_stable_abi_ops_with_torch29_backport: 1 passed in 16.50s

torch 2.11.0.post1+musa5.2.0
torch_musa 2.11.0.post1+musa5.2.0
test_stable_abi_ops_with_native_torch211_abi: 1 passed in 16.28s

The same vLLM-derived weak_ref_tensor operation is compiled and executed in both environments. The torch 2.9 case asserts that the compatibility backport runs; the torch 2.11 case fails if torchada attempts the backport and compiles without torchada's stable compatibility include or force-included boxer header.

Full torchada pytest suite on commit 2b846dd, using the same MTT S5000 and upgrading torch/torch_musa in place between runs:

python -m pytest -q
torch 2.9.1.post1+musa5.2.0 / torch_musa 2.9.1.post1+musa5.2.0
430 passed, 19 skipped, 3 warnings in 54.69s

torch 2.11.0.post1+musa5.2.0 / torch_musa 2.11.0.post1+musa5.2.0
430 passed, 19 skipped, 5 warnings in 55.35s

The additional warnings on torch 2.11 are profiler and TorchScript deprecation warnings; both runs completed without test failures. Downstream vLLM-MUSA build and serving validation is intentionally left to a separate integration effort.

@WindDaoist
WindDaoist force-pushed the fix/protect-dependency-porting branch from 8f79b0a to 9346f0b Compare July 29, 2026 06:48
Comment thread src/torchada/utils/cpp_extension.py Outdated
@WindDaoist
WindDaoist force-pushed the fix/protect-dependency-porting branch from 2f5c290 to 4834445 Compare July 29, 2026 08:30
Comment thread src/torchada/utils/cpp_extension.py Outdated
@WindDaoist
WindDaoist force-pushed the fix/protect-dependency-porting branch from 4834445 to 085a2b5 Compare July 29, 2026 08:41
@WindDaoist
WindDaoist force-pushed the fix/protect-dependency-porting branch from 822ed01 to 85f6c67 Compare August 3, 2026 07:04
@yeahdongcn

Copy link
Copy Markdown
Collaborator

@Joey-gvwal Please take a look. Thanks!

Comment thread src/torchada/utils/cpp_extension.py
@yeahdongcn yeahdongcn changed the title fix: protect dependency headers during extension builds fix: protect dependency headers and align stable ABI versions Aug 3, 2026
@WindDaoist
WindDaoist force-pushed the fix/protect-dependency-porting branch from 15b775c to eb3638c Compare August 3, 2026 09:44
@yeahdongcn
yeahdongcn merged commit df4c461 into MooreThreads:main Aug 3, 2026
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.

3 participants