Skip to content

Consolidate CUDA helpers and remove the legacy _C extension in place of Stable-ABI - #9633

Merged
NicolasHug merged 2 commits into
mainfrom
adabeyta/cuda-stable
Aug 27, 2026
Merged

NicolasHug merged 2 commits into
mainfrom
adabeyta/cuda-stable

Conversation

@adabeyta

Copy link
Copy Markdown
Collaborator

#9626 ported the last op out of _C, so the legacy unstable extension along with dual build is no longer needed. This PR removes and builds every source into _C_stable.

Notes

  • setup.py: make_C_extension(), STABLE_SOURCES, _not_stable() and _stable() are removed. make_C_stable_extension() globs everything under csrc/ (minus io/image) instead of filtering by list, so there is no longer a hand-maintained source list to keep in sync.

  • CMakeLists.txt: the TORCHVISION_STABLE_SOURCES list is deleted for the same reason.

  • get_stable_macros_and_flags() is merged into get_macros_and_flags() per its TODO(stable-abi). The flags are moved, not changed: TORCH_TARGET_VERSION, USE_CUDA (non-ROCm) and USE_MPS are now library-wide since every source is stable. ops/cuda/cuda_helpers.h after the CUDA helper consolidation in this PR.

  • torchvision/csrc/vision.cpp is no longer needed as vision_stable.cpp (Windows PyInit stub, cuda_version(), the _cuda_version op registration) now live behind the stable API.

  • torchvision/extension.py loads only _C_stable.

Stable-ABI audit (torch-abi-audit)

Ran torch-abi-audit. _C.so no longer exists, so the package as a whole now audits STABLE.

Package: torchvision
  Torch ABI:   STABLE
  CPython ABI: n/a
  Bundled libs: 2
  -- bundled libs --
    [STABLE  ] [not-abi3] _C_stable.so     (stable_shim=74, unstable=0)
    [STABLE  ] [not-abi3] image_stable.so  (stable_shim=78, unstable=0)

Every stable CUDA kernel fetched its stream through the same four line
shim snippet. It now lives once in cuda_helpers.h as
get_current_cuda_stream(), the stable counterpart of the single
at::cuda::getCurrentCUDAStream() call the legacy kernels used.
With every op ported the only thing left in _C was the _cuda_version
registration. It moves to vision_stable.cpp, vision.cpp is removed, and
setup.py / CMakeLists.txt build a single stable extension with the torch
version pin applied library wide.
@pytorch-bot

pytorch-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9633

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 Unclassified Failure

As of commit 3b01b14 with merge base 541c083 (image):

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the cla signed label Aug 26, 2026
@adabeyta adabeyta changed the title [ Test ] Consolidate CUDA helpers and remove the legacy _C extension in place of Stable-ABI [Test] Consolidate CUDA helpers and remove the legacy _C extension in place of Stable-ABI Aug 26, 2026
@adabeyta
adabeyta marked this pull request as ready for review August 26, 2026 17:59
@adabeyta
adabeyta requested a review from NicolasHug August 26, 2026 18:00
@adabeyta adabeyta changed the title [Test] Consolidate CUDA helpers and remove the legacy _C extension in place of Stable-ABI Consolidate CUDA helpers and remove the legacy _C extension in place of Stable-ABI Aug 26, 2026
@NicolasHug
NicolasHug merged commit 9e21b88 into main Aug 27, 2026
63 checks passed
@NicolasHug
NicolasHug deleted the adabeyta/cuda-stable branch August 27, 2026 08:09
@NicolasHug

Copy link
Copy Markdown
Member

Thank you so much for the fantastic work @adabeyta !! I'm very happy that torchvision is stable now.

I'll cherry-pick all of this into the 2.14 release branch.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants