Skip to content

[Pyspeech] avoid .item call in feature_processing #4015

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

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

Conversation

ynonaolga
Copy link

Summary:
tensor.item() causes CPU_GPU sync and degradates performance.
Avoid using .item() and rewrite mask_along_axis_iid to treat mask_value as a tensor

comparison https://fburl.com/mlhub/37l2ufrp
{F1980844270}

It increases SM U by 1%
{F1980890373}
{F1980890377}

Differential Revision: D79451615

@ynonaolga ynonaolga requested a review from a team as a code owner August 4, 2025 13:29
Copy link

pytorch-bot bot commented Aug 4, 2025

🔗 Helpful Links

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

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

❌ 8 New Failures, 2 Unrelated Failures

As of commit 02d6815 with merge base c819dbe (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs 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.

@meta-cla meta-cla bot added the CLA Signed label Aug 4, 2025
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 4, 2025
Summary:

tensor.item() causes CPU_GPU sync and degradates performance.
Avoid using .item() and rewrite mask_along_axis_iid to treat mask_value as a tensor

comparison https://fburl.com/mlhub/37l2ufrp
{F1980844270}

It increases SM U by 1%
{F1980890373}
{F1980890377}

Differential Revision: D79451615
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 4, 2025
Summary:
Pull Request resolved: pytorch#4015

tensor.item() causes CPU_GPU sync and degradates performance.
Avoid using .item() and rewrite mask_along_axis_iid to treat mask_value as a tensor

comparison https://fburl.com/mlhub/37l2ufrp
{F1980844270}

It increases SM U by 1%
{F1980890373}
{F1980890377}

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 4, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 7, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 7, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 7, 2025
Summary:
Pull Request resolved: pytorch#4015

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 7, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 7, 2025
Summary:
Pull Request resolved: pytorch#4015

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@ynonaolga ynonaolga force-pushed the export-D79451615 branch 2 times, most recently from acb94a7 to 3196abd Compare August 8, 2025 09:37
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:
Pull Request resolved: pytorch#4015

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:
Pull Request resolved: pytorch#4015

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
Summary:
Pull Request resolved: pytorch#4015

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
ynonaolga added a commit to ynonaolga/audio that referenced this pull request Aug 8, 2025
Summary:

Add support for mask_value to be tensor: for example, if we want to fill with mean values of featured.

when mask_value is tensor masked_fill creates additional D2D copy, rewriting with torch.where to avoid it

Differential Revision: D79451615
@facebook-github-bot
Copy link
Contributor

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

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

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

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