Skip to content

[Paddle] Support recompute - #412

Merged
timmoon10 merged 8 commits into
NVIDIA:mainfrom
Tom-Zheng:gh_add_recompute
Sep 6, 2023
Merged

[Paddle] Support recompute#412
timmoon10 merged 8 commits into
NVIDIA:mainfrom
Tom-Zheng:gh_add_recompute

Conversation

@Tom-Zheng

Copy link
Copy Markdown
Contributor

This PR supports recompute for TE Paddle. The user can use te.recompute to wrap TE layers, or use recompute_core_attention=True in TransformerLayer.forward to recompute only the core attention part.

@Tom-Zheng

Tom-Zheng commented Aug 31, 2023

Copy link
Copy Markdown
ContributorAuthor

Add @jeng1220 to take a look.

@timmoon10timmoon10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tom-Zheng
Tom-Zheng marked this pull request as draft September 2, 2023 06:18
@Tom-ZhengTom-Zheng changed the title [Paddle] Support recompute[WIP] [Paddle] Support recomputeSep 2, 2023
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-ZhengTom-Zheng changed the title [WIP] [Paddle] Support recompute[Paddle] Support recomputeSep 3, 2023
@Tom-Zheng
Tom-Zheng marked this pull request as ready for review September 3, 2023 12:38
@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

@timmoon10 There were some changes since your last approval, would you please take a look? cc: @jeng1220

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@Tom-Zheng

Copy link
Copy Markdown
ContributorAuthor

Changes since last approval:

  1. Improve recompute test: added check of memory usage
  2. Improve recompute detection performance: inspect.stack() is slow (and messes with tensor lifetime). Use frame.f_back instead.
  3. Add documentation for rng_name args introduced in [Paddle] Add control of RNG state #410
  4. Other functional fixes

@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

Comment threadtests/paddle/test_recompute.py Outdated
"""
# Create 'script.py' file
with open('script.py', 'w', encoding="utf8") as script_file:
script_file.write(script_content)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just create a file for the code instead of using a string.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
@jeng1220

Copy link
Copy Markdown
Contributor

LGTM.

@zlsh80826

Copy link
Copy Markdown
Collaborator

/te-ci

@jeng1220

Copy link
Copy Markdown
Contributor

@timmoon10 ,

There are some UT failures but they are not related to this PR:

  • te-ci/L0_jax_unittest--A100_1GPU
  • te-ci/L0_jax_unittest--H100_1GPU
  • te-ci/L0_jax_unittest--V100_1GPU
  • te-ci/L0_unittest--H100_1GPU

Please review and merge the code if everything looks good.
Thank you.

@timmoon10
timmoon10 merged commit 45a2ac4 into NVIDIA:mainSep 6, 2023
RuiWang1998 pushed a commit to RuiWang1998/TransformerEngine that referenced this pull request Sep 11, 2023
* Add recompute
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Support recompute core attention
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix transformer layer recompute
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Add doc
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve recompute test
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve performance of stack backtrace
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Improve code stype
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
* Fix code style
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
---------
Signed-off-by: Tian Zheng (Engrg-Hardware 1) <tizheng@nvidia.com>
Signed-off-by: Rui Wang <rui@helixon.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Tom-Zheng@zlsh80826@jeng1220@timmoon10