Skip to content

[MPS Delegate] Add new mps runtime with support for FP16, lifted and unlifted graphs (iOS15+, macOS12+)#1655

Closed
DenisVieriu97 wants to merge 4 commits intopytorch:mainfrom
DenisVieriu97:denis/new_mps_delegate_runtime
Closed

[MPS Delegate] Add new mps runtime with support for FP16, lifted and unlifted graphs (iOS15+, macOS12+)#1655
DenisVieriu97 wants to merge 4 commits intopytorch:mainfrom
DenisVieriu97:denis/new_mps_delegate_runtime

Conversation

@DenisVieriu97
Copy link
Contributor

@DenisVieriu97 DenisVieriu97 commented Jan 19, 2024

This PR changes the MPS Backend runtime to support for iOS15+/macOS12+ (previous runtime was limited to iOS17/macOS14 only). Additionally, this PR contains changes such as support for both lifted and unlifted graphs, support for torch.export API, optimizations for FP16 and faster model loading during runtime (more information in the summary).

Summary of changes:

  • Add support for running the models in FP16 (https://github.com/DenisVieriu97/executorch/pull/7 @georgepaw)
  • Replace the previous MPS runtime from ExecuTorch which was relying on iOS17 / macOS Sonoma APIs for serialization of the MPSGraphExecutable. Instead of creating the MPSGraph nodes and serializing them during AOT, create the corresponding entries of the EdgeIR nodes in the FlatBuffer, and parse them during runtime to construct the graph. This removes any dependency on iOS17 / macOS 14.0 APIs.
  • Add support for node visitor pattern:
    • Each node visitor class visits an op and serializes the data into MPSTensors and MPSNodes which get appended in the flatbuffer
    • The entries from the FlatBuffer are parsed in the runtime and based on them the MPSGraph is constructed (for more info see MPSGraphBuilder class and corresponding ops from operators/ folder.
    • This method removes the additional read and writes to disk of the MPSGraphExecutable (once during AOT and once during runtime).

Models summary:

Model FP16 FP32
mul
add_mul
linear
edsr
Mobilebert
mv2
mv3
vit
w2l
ic3
ic4
resnet18
resnet50
Llama2
emformer_join
emformer_predict
emformer_transcribe
dl3

@pytorch-bot
Copy link

pytorch-bot bot commented Jan 19, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 8d94299 with merge base 93dd96f (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 19, 2024
@DenisVieriu97 DenisVieriu97 changed the title [MPS Delegate] Add new mps runtime with support for FP16, lifted and unlifted graphs… [MPS Delegate] Add new mps runtime with support for FP16, lifted and unlifted graphs (iOS15+, macOS12+) Jan 19, 2024
@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

5 similar comments
@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@DenisVieriu97 DenisVieriu97 force-pushed the denis/new_mps_delegate_runtime branch from 345c198 to 923d30a Compare January 22, 2024 07:09
@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@shoumikhin has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@shoumikhin merged this pull request in cbc0c95.

facebook-github-bot pushed a commit that referenced this pull request Jan 23, 2024
Summary:
Pull Request resolved: #1671

After #1655 is merged we should be able to run iOS CI on iOS 16+.

Reviewed By: cccclai

Differential Revision: D52961924

fbshipit-source-id: 30b07fe97f11a240cf84c9716ef3fe48807ad076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants