Skip to content

[MTIA ATen Backend][1/n] Migrate "_unsafe_view" and "view" ops from out-of-tree to pytorch in-tree #153670

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 1 commit into from

Conversation

andyanwang
Copy link
Contributor

@andyanwang andyanwang commented May 15, 2025

Summary:

Context

The MTIA New Aten Backend work is essentially to move MTIA operators from pytorch out-of-tree to in-tree, with following benefits:

  1. Avoid duplicate code copied from pytorch, e.g. view ops implementation, util functions.
  2. Utilize TensorIterator and structured kernel codegen, avoid manual implementation of broadcasting, dtype casting, asserting, etc.
  3. Eliminate MTIA's own codegen flow, which is unnecessary complexity.
  4. Overall make MTIA's aten backend more pytorch native.

Differential Revision: D74672464

cc @egienvalue

Copy link

pytorch-bot bot commented May 15, 2025

This appears to be a diff that was exported from phabricator, but the PR author does not have sufficient permissions to run CI. @andyanwang, please do step 2 of internal wiki to get write access so you do not need to get CI approvals in the future. If you think this is a mistake, please contact the Pytorch Dev Infra team.

Copy link

linux-foundation-easycla bot commented May 15, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

pytorch-bot bot commented May 15, 2025

🔗 Helpful Links

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

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

✅ No Failures

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

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

@facebook-github-bot
Copy link
Contributor

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

andyanwang added a commit to andyanwang/pytorch that referenced this pull request May 15, 2025
…-tree to pytorch in-tree (pytorch#153670)

Summary:

# Context
The MTIA New Aten Backend work is essentially to move MTIA operators from pytorch out-of-tree to in-tree, with following benefits:
1. Avoid duplicate code copied from pytorch, e.g. view ops implementation, util functions.
2. Utilize TensorIterator and structured kernel codegen, avoid manual implementation of broadcasting, dtype casting, asserting, etc.
3. Eliminate MTIA's own codegen flow, which is unnecessary complexity.
4. Overall make MTIA's aten backend more pytorch native.

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

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

Copy link
Contributor

Attention! native_functions.yaml was changed

If you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info.


Caused by:

Copy link

pytorch-bot bot commented May 16, 2025

❌ 🤖 pytorchbot command failed:

Got EOF while in a quoted string```
Try `@pytorchbot --help` for more info.

@andyanwang
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label May 16, 2025
@facebook-github-bot
Copy link
Contributor

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

andyanwang added a commit to andyanwang/pytorch that referenced this pull request May 16, 2025
…-tree to pytorch in-tree (pytorch#153670)

Summary:

# Context
The MTIA New Aten Backend work is essentially to move MTIA operators from pytorch out-of-tree to in-tree, with following benefits:
1. Avoid duplicate code copied from pytorch, e.g. view ops implementation, util functions.
2. Utilize TensorIterator and structured kernel codegen, avoid manual implementation of broadcasting, dtype casting, asserting, etc.
3. Eliminate MTIA's own codegen flow, which is unnecessary complexity.
4. Overall make MTIA's aten backend more pytorch native.

Differential Revision: D74672464
…-tree to pytorch in-tree (pytorch#153670)

Summary:

# Context
The MTIA New Aten Backend work is essentially to move MTIA operators from pytorch out-of-tree to in-tree, with following benefits:
1. Avoid duplicate code copied from pytorch, e.g. view ops implementation, util functions.
2. Utilize TensorIterator and structured kernel codegen, avoid manual implementation of broadcasting, dtype casting, asserting, etc.
3. Eliminate MTIA's own codegen flow, which is unnecessary complexity.
4. Overall make MTIA's aten backend more pytorch native.

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

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

@nautsimon nautsimon requested review from malfet and nautsimon May 19, 2025 15:13
@nautsimon nautsimon added the module: mtia Device MTIA related issues label May 19, 2025
@nautsimon nautsimon requested review from egienvalue and albanD May 19, 2025 15:18
@nautsimon nautsimon changed the title [MTIA Aten Backend] Migrate "_unsafe_view" and "view" ops from out-of-tree to pytorch in-tree [MTIA ATen Backend] Migrate "_unsafe_view" and "view" ops from out-of-tree to pytorch in-tree May 19, 2025
@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 19, 2025
@nautsimon nautsimon requested review from leafs1, swolchok, hl475 and etaf and removed request for leafs1 May 20, 2025 21:22
andyanwang added a commit that referenced this pull request Jun 26, 2025
…rward"

# Context

See the first PR #153670

# This diff

 Migrate log_sigmoid_forward to in-tree.

Differential Revision: [D77191668](https://our.internmc.facebook.com/intern/diff/D77191668/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jun 26, 2025
# Context

See the first PR #153670

# This diff

 Migrate log_sigmoid_forward to in-tree.

Differential Revision: [D77191668](https://our.internmc.facebook.com/intern/diff/D77191668/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 21, 2025
… / eq.Scalar_out

# Context

See the first PR #153670

# This diff

 Migrate addcdiv.out / addcmul.out / eq.Tensor_out / eq.Scalar_out to in-tree.

Differential Revision: [D78568103](https://our.internmc.facebook.com/intern/diff/D78568103/)

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 21, 2025
# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 21, 2025
# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)

ghstack-source-id: 297160102
Pull Request resolved: #158749
andyanwang added a commit that referenced this pull request Jul 22, 2025
Pull Request resolved: #158749

# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)
ghstack-source-id: 297792774
andyanwang added a commit that referenced this pull request Jul 22, 2025
…addcmul.out / eq.Tensor_out / eq.Scalar_out"

# Context

See the first PR #153670

# This diff

 Migrate addcdiv.out / addcmul.out / eq.Tensor_out / eq.Scalar_out to in-tree.

Differential Revision: [D78568103](https://our.internmc.facebook.com/intern/diff/D78568103/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 22, 2025
….Tensor_out / eq.Scalar_out"

# Context

See the first PR #153670

# This diff

 Migrate addcdiv.out / addcmul.out / eq.Tensor_out / eq.Scalar_out to in-tree.

Differential Revision: [D78568103](https://our.internmc.facebook.com/intern/diff/D78568103/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 22, 2025
…ddbmm.out / bmm.out"

# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 22, 2025
…out"

# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)

cc egienvalue

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Jul 23, 2025
… / eq.Scalar_out (#158748)

# Context

See the first PR #153670

# This diff

 Migrate addcdiv.out / addcmul.out / eq.Tensor_out / eq.Scalar_out to in-tree.

Differential Revision: [D78568103](https://our.internmc.facebook.com/intern/diff/D78568103/)

Pull Request resolved: #158748
Approved by: https://github.com/albanD, https://github.com/nautsimon
pytorchmergebot pushed a commit that referenced this pull request Jul 23, 2025
# Context

See the first PR #153670

# This diff

 Migrate addmm.out / baddbmm.out / bmm.out to in-tree.

Differential Revision: [D78578483](https://our.internmc.facebook.com/intern/diff/D78578483/)

Pull Request resolved: #158749
Approved by: https://github.com/albanD, https://github.com/nautsimon
ghstack dependencies: #158748
andyanwang added a commit that referenced this pull request Jul 24, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 24, 2025
Pull Request resolved: #159098

# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

ghstack-source-id: 298446017
@exported-using-ghexport

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)
andyanwang added a commit that referenced this pull request Jul 25, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 25, 2025
Pull Request resolved: #159098

# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

ghstack-source-id: 298481964
@exported-using-ghexport

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)
andyanwang added a commit that referenced this pull request Jul 31, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 31, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 31, 2025
Pull Request resolved: #159540

# Context

See the first PR #153670

# This diff

 Migrate arange.start_out to in-tree.

We can use this diff as an example for non-structured operator.

ghstack-source-id: 299962562
@exported-using-ghexport

Differential Revision: [D79317519](https://our.internmc.facebook.com/intern/diff/D79317519/)
andyanwang added a commit that referenced this pull request Jul 31, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Jul 31, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

cc egienvalue

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Aug 1, 2025
# Context

See the first PR #153670

# This diff

 Migrate all foreach operators to in-tree, including:
  - _foreach_abs
  - _foreach_abs_
  - _foreach_add.List
  - _foreach_add_.List
  - _foreach_add_.Scalar
  - _foreach_add_.Tensor
  - _foreach_addcmul.Scalar
  - _foreach_addcmul_.Scalar
  - _foreach_copy
  - _foreach_copy_
  - _foreach_mul.List
  - _foreach_mul_.List
  - _foreach_mul_.Scalar
  - _foreach_mul.Tensor
  - _foreach_mul_.Tensor
  - _foreach_norm.Scalar
  - _foreach_sqrt_

Differential Revision: [D78913847](https://our.internmc.facebook.com/intern/diff/D78913847/)

Pull Request resolved: #159098
Approved by: https://github.com/malfet
andyanwang added a commit that referenced this pull request Aug 4, 2025
Pull Request resolved: #159540

# Context

See the first PR #153670

# This diff

 Migrate arange.start_out to in-tree.

We can use this diff as an example for non-structured operator.

ghstack-source-id: 300416010
@exported-using-ghexport

Differential Revision: [D79317519](https://our.internmc.facebook.com/intern/diff/D79317519/)
andyanwang added a commit that referenced this pull request Aug 4, 2025
…xample diff for tutorial)"


Differential Revision: [D79524919](https://our.internmc.facebook.com/intern/diff/D79524919/)

# Context

See the first PR #153670

# This diff

 Migrate any.all_out to in-tree.

We can use this diff as an example for in-tree registration.

[ghstack-poisoned]
andyanwang added a commit that referenced this pull request Aug 4, 2025
Pull Request resolved: #159780

# Context

See the first PR #153670

# This diff

 Migrate any.all_out to in-tree.

We can use this diff as an example for in-tree registration.

Differential Revision: [D79524919](https://our.internmc.facebook.com/intern/diff/D79524919/)
ghstack-source-id: 300591646
andyanwang added a commit that referenced this pull request Aug 4, 2025
…tutorial)"


Differential Revision: [D79524919](https://our.internmc.facebook.com/intern/diff/D79524919/)

# Context

See the first PR #153670

# This diff

 Migrate any.all_out to in-tree.

We can use this diff as an example for in-tree registration.

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged module: mtia Device MTIA related issues topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants