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

[DTensor] implement layout converter #3055

Merged

Conversation

YuliangLiu0306
Copy link
Contributor

@YuliangLiu0306 YuliangLiu0306 commented Mar 8, 2023

📌 Checklist before creating the PR

  • I have created an issue for this PR for traceability
  • The title follows the standard format: [doc/gemini/tensor/...]: A concise description
  • I have added relevant tags if possible for us to better distinguish different PRs

🚨 Issue number

#3067

📝 What does this PR do?

LayoutConverter mainly has three main functions:

  1. Search an efficient transform path for the given pair of source_layout and target_layout.
  2. Estimate the converting cost for the given pair of source_layout and target_layout.
  3. Apply the layout converting path to redistribute a tensor from source_layout to target_layout.

To search the transform path, we use a heuristic algorithm which could be simplily describe as:

  • Step1: Generate all one-step transform sequences from source_layout.
  • Step2: Pick the 'best' layout following the heuristic function.
  • Step3: Repeat above steps until the source layout transform to target layout.

To estimate the total converting cost, we implement a method to estimate the communication cost of each communication operation under the instruction of CommSpec. Then, we just need sum the costs of CommSpec in the transform_sequence up to get the total converting cost.

💥 Checklist before requesting a review

  • I have linked my PR to an issue (instruction)
  • My issue clearly describes the problem/feature/proposal, with diagrams/charts/table/code if possible
  • I have performed a self-review of my code
  • I have added thorough tests.
  • I have added docstrings for all the functions/methods I implemented

⭐️ Do you enjoy contributing to Colossal-AI?

  • 🌝 Yes, I do.
  • 🌚 No, I don't.

Tell us more if you don't enjoy contributing to Colossal-AI.

@YuliangLiu0306 YuliangLiu0306 marked this pull request as draft March 8, 2023 07:59
@YuliangLiu0306 YuliangLiu0306 changed the title Feature/implement layout converter [DTensor] implement layout converter Mar 8, 2023
@YuliangLiu0306 YuliangLiu0306 marked this pull request as ready for review March 9, 2023 05:43
@YuliangLiu0306 YuliangLiu0306 linked an issue Mar 9, 2023 that may be closed by this pull request
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

The code coverage for the changed files is %.

Click me to view the complete report
Name                                                      Stmts   Miss  Cover
-----------------------------------------------------------------------------
colossalai/tensor/d_tensor/layout_converter.py              200     24    88%
colossalai/tensor/d_tensor/utils.py                          38      7    82%
tests/test_tensor/test_dtensor/test_layout_converter.py      97      1    99%
-----------------------------------------------------------------------------
TOTAL                                                       335     32    90%

@FrankLeeeee
Copy link
Contributor

Looks good to me.

@FrankLeeeee FrankLeeeee merged commit 8e4e860 into hpcaitech:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Implement LayoutConverter
2 participants