Skip to content
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

Metal: Removing fences as they seem to not be needed. #1492

Closed
wants to merge 1 commit into from

Conversation

ivarflakstad
Copy link
Member

Updating/waiting for fences was initially added to help tackle GPU race condition bugs. However I think that the bug was fixed and that these fences are no longer needed.

@Narsil what do you think? Seems to work perfectly on the m1 pro (faster too)

@ivarflakstad ivarflakstad requested a review from Narsil December 28, 2023 16:35
@ivarflakstad ivarflakstad self-assigned this Dec 28, 2023
@Narsil
Copy link
Collaborator

Narsil commented Dec 28, 2023

No it's keeps failing on m3. You can repro with my gist https://gist.github.com/Narsil/13bfeb66959a0b7e2750a23be9ecc957.

Also how did you test and what did you measure. On m3 the fence is quite negligible (as long as the scheduler is kept happy by leaving a few critical ones)

Also you cannot remove fences inside a single command encoder. This is specifically written as non ordered by default.

@ivarflakstad
Copy link
Member Author

No it's keeps failing on m3. You can repro with my gist https://gist.github.com/Narsil/13bfeb66959a0b7e2750a23be9ecc957.

I get the following - I assume you do not?

First matmul is OK [2.0, 3.0, 6.0, 11.0, 46.0, 55.0, 66.0, 79.0]
This should be filled [6.0, 11.0, 22.0, 39.0, 514.0, 615.0, 738.0, 883.0]

Also how did you test and what did you measure. On m3 the fence is quite negligible (as long as the scheduler is kept happy by leaving a few critical ones)

Ran some models and the difference was significant. However I just did a reboot and the difference is gone 🤷
Guess I'll close

@ivarflakstad
Copy link
Member Author

Reopening as it seems the fence situation has changed for M3.
Is that correct, @Narsil ?😊

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.

2 participants