Skip to content

[CuTe] Add type for CuTe layout via claude#162534

Closed
fduwjj wants to merge 8 commits intogh/fduwjj/194/basefrom
gh/fduwjj/194/head
Closed

[CuTe] Add type for CuTe layout via claude#162534
fduwjj wants to merge 8 commits intogh/fduwjj/194/basefrom
gh/fduwjj/194/head

Conversation

@fduwjj
Copy link
Contributor

@fduwjj fduwjj commented Sep 9, 2025

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 9, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 0428777 with merge base 5babb4d (image):
💚 Looks good so far! There are no failures yet. 💚

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

fduwjj added a commit that referenced this pull request Sep 9, 2025
ghstack-source-id: 2a11926
Pull Request resolved: #162534
@pytorch-bot pytorch-bot bot added the oncall: distributed Add this issue/PR to distributed oncall triage queue label Sep 9, 2025
@fduwjj fduwjj requested review from ezyang and fegin September 9, 2025 22:25
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.


cc H-Huang awgu wanchaol fegin wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
@ezyang
Copy link
Contributor

ezyang commented Sep 10, 2025

You should be able to feed my CR comments directly to Claude. Please review the output yourself though.

This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.


cc H-Huang awgu wanchaol fegin wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
fduwjj added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: 0cec363
Pull Request resolved: #162534
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.


cc H-Huang awgu wanchaol fegin wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
fduwjj added a commit that referenced this pull request Sep 10, 2025
ghstack-source-id: 9ed51e9
Pull Request resolved: #162534
@fduwjj fduwjj requested review from Skylion007 and ezyang September 10, 2025 17:14
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.


cc H-Huang awgu wanchaol fegin wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
@fduwjj
Copy link
Contributor Author

fduwjj commented Sep 12, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Sep 12, 2025
… DeviceMesh (#162414)

We create a wrapper class acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in #161016)

Pull Request resolved: #162414
Approved by: https://github.com/ezyang
ghstack dependencies: #162413, #162534
pytorchmergebot pushed a commit that referenced this pull request Sep 15, 2025
… DeviceMesh (#162414)

We create a wrapper class named "_MeshLayout" acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in #161016)

Pull Request resolved: #162414
Approved by: https://github.com/ezyang, https://github.com/fegin
ghstack dependencies: #162413, #162534
pytorchmergebot pushed a commit that referenced this pull request Sep 16, 2025
…plement from co-lex to lex (#162690)

PyTorch tensor iteration (.view, contiguous, broadcasting) and NumPy array indexing all follow lexicographic (row-major) order. In Lexicographic (lex) on (i0, i1, …, i{k-1}): the leftmost index(stride is larger) changes fastest and the rightmost index changes slowest and usually last dim is contiguous.

However original pycute is all based on co-lex, after porting their code into pytorch and some cosmetic change, we now make it lex so that we can use it for use cases like device mesh internal bookkeeping and other stuff as well.

Changes included in this PR:
1. We changes all API ported in, included prefix_product(stride inferring and rename it to suffix_product), idx2crd, crd2idx, coalesce, composition, complement, right_inverse and left_inverse to make sure they are working in the lex way.
2. Added more unit test cases for some API mentioned above since existing unit tests do not have full coverage.
3. One bug fix inside composition, which will lead to infinite recursive call.

Pull Request resolved: #162690
Approved by: https://github.com/ezyang
ghstack dependencies: #162413, #162534, #162414
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.
We removed all suppressions of linters and add type checker, type alias and mypy ignore(if needed) so that the pycute code will be checked by linter.

Pull Request resolved: pytorch#162534
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#162413
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class named "_MeshLayout" acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang, https://github.com/fegin
ghstack dependencies: pytorch#162413, pytorch#162534
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
…plement from co-lex to lex (pytorch#162690)

PyTorch tensor iteration (.view, contiguous, broadcasting) and NumPy array indexing all follow lexicographic (row-major) order. In Lexicographic (lex) on (i0, i1, …, i{k-1}): the leftmost index(stride is larger) changes fastest and the rightmost index changes slowest and usually last dim is contiguous.

However original pycute is all based on co-lex, after porting their code into pytorch and some cosmetic change, we now make it lex so that we can use it for use cases like device mesh internal bookkeeping and other stuff as well.

Changes included in this PR:
1. We changes all API ported in, included prefix_product(stride inferring and rename it to suffix_product), idx2crd, crd2idx, coalesce, composition, complement, right_inverse and left_inverse to make sure they are working in the lex way.
2. Added more unit test cases for some API mentioned above since existing unit tests do not have full coverage.
3. One bug fix inside composition, which will lead to infinite recursive call.

Pull Request resolved: pytorch#162690
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534, pytorch#162414
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.
We removed all suppressions of linters and add type checker, type alias and mypy ignore(if needed) so that the pycute code will be checked by linter.

Pull Request resolved: pytorch#162534
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#162413
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class named "_MeshLayout" acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang, https://github.com/fegin
ghstack dependencies: pytorch#162413, pytorch#162534
mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
…plement from co-lex to lex (pytorch#162690)

PyTorch tensor iteration (.view, contiguous, broadcasting) and NumPy array indexing all follow lexicographic (row-major) order. In Lexicographic (lex) on (i0, i1, …, i{k-1}): the leftmost index(stride is larger) changes fastest and the rightmost index changes slowest and usually last dim is contiguous.

However original pycute is all based on co-lex, after porting their code into pytorch and some cosmetic change, we now make it lex so that we can use it for use cases like device mesh internal bookkeeping and other stuff as well.

Changes included in this PR:
1. We changes all API ported in, included prefix_product(stride inferring and rename it to suffix_product), idx2crd, crd2idx, coalesce, composition, complement, right_inverse and left_inverse to make sure they are working in the lex way.
2. Added more unit test cases for some API mentioned above since existing unit tests do not have full coverage.
3. One bug fix inside composition, which will lead to infinite recursive call.

Pull Request resolved: pytorch#162690
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534, pytorch#162414
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.
We removed all suppressions of linters and add type checker, type alias and mypy ignore(if needed) so that the pycute code will be checked by linter.

Pull Request resolved: pytorch#162534
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#162413
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class named "_MeshLayout" acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang, https://github.com/fegin
ghstack dependencies: pytorch#162413, pytorch#162534
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
…plement from co-lex to lex (pytorch#162690)

PyTorch tensor iteration (.view, contiguous, broadcasting) and NumPy array indexing all follow lexicographic (row-major) order. In Lexicographic (lex) on (i0, i1, …, i{k-1}): the leftmost index(stride is larger) changes fastest and the rightmost index changes slowest and usually last dim is contiguous.

However original pycute is all based on co-lex, after porting their code into pytorch and some cosmetic change, we now make it lex so that we can use it for use cases like device mesh internal bookkeeping and other stuff as well.

Changes included in this PR:
1. We changes all API ported in, included prefix_product(stride inferring and rename it to suffix_product), idx2crd, crd2idx, coalesce, composition, complement, right_inverse and left_inverse to make sure they are working in the lex way.
2. Added more unit test cases for some API mentioned above since existing unit tests do not have full coverage.
3. One bug fix inside composition, which will lead to infinite recursive call.

Pull Request resolved: pytorch#162690
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534, pytorch#162414
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
This PR mostly is a cosmetic change using Claude to add types for copied PyCute code.
We removed all suppressions of linters and add type checker, type alias and mypy ignore(if needed) so that the pycute code will be checked by linter.

Pull Request resolved: pytorch#162534
Approved by: https://github.com/ezyang, https://github.com/Skylion007
ghstack dependencies: pytorch#162413
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
… DeviceMesh (pytorch#162414)

We create a wrapper class named "_MeshLayout" acting as a layout for device mesh so that we can add new methods more specific to DeviceMesh and keep the core logic of CuTe manipulation inside pycute module. This PR create the main body of the code and then next PR will come with actual implementation and unit test for device mesh layout. (Actual implementation can be found in pytorch#161016)

Pull Request resolved: pytorch#162414
Approved by: https://github.com/ezyang, https://github.com/fegin
ghstack dependencies: pytorch#162413, pytorch#162534
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
…plement from co-lex to lex (pytorch#162690)

PyTorch tensor iteration (.view, contiguous, broadcasting) and NumPy array indexing all follow lexicographic (row-major) order. In Lexicographic (lex) on (i0, i1, …, i{k-1}): the leftmost index(stride is larger) changes fastest and the rightmost index changes slowest and usually last dim is contiguous.

However original pycute is all based on co-lex, after porting their code into pytorch and some cosmetic change, we now make it lex so that we can use it for use cases like device mesh internal bookkeeping and other stuff as well.

Changes included in this PR:
1. We changes all API ported in, included prefix_product(stride inferring and rename it to suffix_product), idx2crd, crd2idx, coalesce, composition, complement, right_inverse and left_inverse to make sure they are working in the lex way.
2. Added more unit test cases for some API mentioned above since existing unit tests do not have full coverage.
3. One bug fix inside composition, which will lead to infinite recursive call.

Pull Request resolved: pytorch#162690
Approved by: https://github.com/ezyang
ghstack dependencies: pytorch#162413, pytorch#162534, pytorch#162414
@github-actions github-actions bot deleted the gh/fduwjj/194/head branch October 13, 2025 02:15
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 Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: DeviceMesh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants