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

avoid using warning tensor in cpu tbe op #3631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

842974287
Copy link
Contributor

Summary:
The main reason for the change is because this can cause crashes for some models https://fburl.com/tupperware/1rt3jvj7.

I'm not entirely sure why there's crashes in this line https://fburl.com/code/x8obwbue when we call __sync_fetch_and_add. Seems like the pointer is invalid but I don't understand why it could be invalid. However, the current impl indeed has a race condition in inference. The warning tensor https://fburl.com/code/1nu3ipli is from this module https://fburl.com/code/99m9lt5e and in inference we have multiple threads calling the cpu ops. Each thread will be modifying the same tensor memory (still not sure why this could invalidate the pointer address though).

Looks like it's not necessary to use a tensor to control the logging once behavior in the cpu op. Removed the usage of warning tensor in the cpu op to fix the race condition.

Differential Revision: D68840262

Summary:
The main reason for the change is because this can cause crashes for some models https://fburl.com/tupperware/1rt3jvj7.

I'm not entirely sure why there's crashes in this line https://fburl.com/code/x8obwbue when we call `__sync_fetch_and_add`. Seems like the pointer is invalid but I don't understand why it could be invalid. However, the current impl indeed has a race condition in inference. The `warning` tensor https://fburl.com/code/1nu3ipli is from this module https://fburl.com/code/99m9lt5e and in inference we have multiple threads calling the cpu ops. Each thread will be modifying the same tensor memory (still not sure why this could invalidate the pointer address though).

Looks like it's not necessary to use a tensor to control the logging once behavior in the cpu op. Removed the usage of `warning` tensor in the cpu op to fix the race condition.

Differential Revision: D68840262
Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 75bf4f9
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/679a6cceea45b20008bf79fe
😎 Deploy Preview https://deploy-preview-3631--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68840262

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