8000 [MPS] Extend `torch.mm`/`torch.bmm` to integral types by malfet · Pull Request #145809 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[MPS] Extend torch.mm/torch.bmm to integral types #145809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from

Conversation

malfet
Copy link
Contributor
@malfet malfet commented Jan 28, 2025

Stack from ghstack (oldest at bottom):

By using naive_mm kernel, but make sure that accumulation is done over int32 for smaller int types (and float for half and bfloat) as well as adding navie_bmm that follows the same pattern.
Remove stale restriction on torch.dot (which works fine on MacOS-14/15)
This also enables integer op flavors for:

  • addmv
  • einsum
  • inner
  • linalg.multi_dot
  • matmul
  • mv
  • tensordot

[ghstack-poisoned]
@malfet malfet requested a review from kulinseth as a code owner January 28, 2025 01:24
@malfet malfet mentioned this pull request Jan 28, 2025
@pytorch-bot pytorch-bot bot added ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Jan 28, 2025
Copy link
pytorch-bot bot commented Jan 28, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 49 Pending

As of commit b15f4af with merge base 6b41f31 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@malfet malfet requested review from Skylion007 and dcci January 28, 2025 01:27
@malfet malfet added the topic: improvements topic category label Jan 28, 2025
[ghstack-poisoned]
malfet added a commit that referenced this pull request Jan 28, 2025
By using naivemm kernel

ghstack-source-id: a993090
Pull Request resolved: #145809
[ghstack-poisoned]
[ghstack-poisoned]
malfet added a commit that referenced this pull request Jan 29, 2025
By using naivemm kernel

ghstack-source-id: a899b05
Pull Request resolved: #145809
[ghstack-poisoned]
[ghstack-poisoned]
@malfet malfet marked this pull request as draft January 30, 2025 14:24
@malfet
Copy link
Contributor Author
malfet commented Jan 30, 2025

Debug script

import torch
import os

os.environ["MTL_CAPTURE_ENABLED"]="1"
torch.manual_seed(42)
x = torch.testing.make_tensor([10,], dtype=torch.int16, device="mps")
y = torch.testing.make_tensor([5, 10, 5], dtype=torch.int16, device="mps")
# x = torch.ones((5, 1, 10,), dtype=torch.int16, device="mps")
#x = torch.randint(-1, 3, (10,), dtype=torch.int16, device="mps")
#y = torch.arange(250, dtype=torch.int16, device="mps").reshape(5, 10, 5)
#with torch.device("mps"):
#    x=torch.arange(15, dtype=torch.int16).reshape(3, 5, 1)
#    y=torch.arange(18, dtype=torch.int16).reshape(3, 1, 6)
#    print(x.stride(), y.stride())

#with torch.mps.profiler.metal_capture("bmm"):
#    z = torch.matmul(x, y)

print(x)
print(y)
z = torch.matmul(x, y)
print(x.stride(), y.stride())
print(z)
print(torch.matmul(x.cpu(), y.cpu()))

[ghstack-poisoned]
@malfet malfet marked this pull request as ready for review January 30, 2025 16:09
[ghstack-poisoned]
@malfet malfet changed the title [MPS] Extend torch.mm to integral types [MPS] Extend torch.mm/torch.bmm to integral types Jan 30, 2025
[ghstack-poisoned]
malfet added a commit that referenced this pull request Jan 30, 2025
By using naivemm kernel

ghstack-source-id: d298124
Pull Request resolved: #145809
[ghstack-poisoned]
malfet added a commit that referenced this pull request Jan 30, 2025
By using naivemm kernel

ghstack-source-id: bb04d86
Pull Request resolved: #145809
@malfet
Copy link
Contributor Author
malfet commented Jan 30, 2025

@pytorchbot merge -f "Lint + MPS are green"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the gh/malfet/152/head branch March 2, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/mps Run MPS tests (subset of trunk) Merged release notes: mps Release notes category topic: improvements topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0