Skip to content

Port roi_align (MPS) to stable ABI. - #9612

Merged
adabeyta merged 1 commit into
mainfrom
adabeyta/roi-align-mps-stable
Aug 18, 2026
Merged

adabeyta merged 1 commit into
mainfrom
adabeyta/roi-align-mps-stable

Conversation

@adabeyta

@adabeyta adabeyta commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

Ports the roi_align MPS kernels to the stable ABI.

Notes

  • Requires [Stable ABI] Add torch_mps_set_arg_bytes to the MPS shim. pytorch#190932
  • Shader source moves to roi_align_metal_shader.h. Once every MPS op migrates, the per-op headers can consolidate to a mps_stable_kernels.h and mps_kernels.h gets dropped.
  • The MPS backward accumulates with atomic_add, so it is nondeterministic and has to say so when torch.use_deterministic_algorithms(True) is set. The kernel used to do that itself at roi_align_kernel.mm , through at::globalContext(). A stable-ABI kernel cannot reach that and there is no stable equivalent so alert moved to the autograd wrapper at _autograd_registrations.py:

Stable-ABI audit (torch-abi-audit)

Ran torch-abi-audit (https://github.com/Quansight/torch-abi-audit) on both MPS builds:

      Package: torchvision
        Torch ABI:   UNSTABLE
        CPython ABI: n/a
        Bundled libs: 3
        -- bundled libs --
          [UNSTABLE] [not-abi3] _C.so            (stable_shim=0,  unstable=91)
          [STABLE  ] [not-abi3] _C_stable.so     (stable_shim=77, unstable=0)
          [STABLE  ] [not-abi3] image_stable.so  (stable_shim=70, unstable=0)

@pytorch-bot

pytorch-bot Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 Unclassified Failure

As of commit 4b8c89c with merge base af77a7c (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 17, 2026
@adabeyta
adabeyta force-pushed the adabeyta/roi-align-mps-stable branch 2 times, most recently from 27cf9a2 to add5e23 Compare August 17, 2026 21:56
@adabeyta adabeyta changed the title [Test] Port roi_align (MPS) to stable ABI. Port roi_align (MPS) to stable ABI. Aug 18, 2026
@adabeyta
adabeyta marked this pull request as ready for review August 18, 2026 12:55
@adabeyta
adabeyta requested a review from NicolasHug August 18, 2026 12:55

@NicolasHug NicolasHug left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @adabeyta !

@adabeyta
adabeyta force-pushed the adabeyta/roi-align-mps-stable branch from add5e23 to 4b8c89c Compare August 18, 2026 20:39
@adabeyta

adabeyta commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks @adabeyta !

NP! I pushed up one small edit that mirrors the existing USE_CUDA handling for USE_MPS. The stable shim declares torch_mps_set_arg_bytes behind #ifdef USE_MPS, so the cmake build needs a similar def.

@adabeyta
adabeyta merged commit 2e9baab into main Aug 18, 2026
63 checks passed
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