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

[Remat][Bugfix] Enhance the rematerialization pass to handle nested tuples #17

Merged
merged 5 commits into from
Apr 17, 2022

Conversation

zhouyuan1119
Copy link
Contributor

@zhouyuan1119 zhouyuan1119 commented Apr 14, 2022

Description

This PR addresses issue #8 and presents a small fix for the rematerialization pass to handle nested tuples. Specifically, it handles cases like the following:

...
let a = (x0, x1)
...
let b = some_call()
...
let c = (a, b)

Without this patch the remat pass would error out when processing c because of a simplified assumption we made in the first version of the pass. Notice that this fix does not address the case where a call node directly produces a nested tuple (which does not exist in current RAF as far as I know).

ResNet50 with AMP can now be compiled with rematerialization turned on, and the benchmarked latency is ~35ms per batch when the batch size is 16.

I will add a test for nested tuples later. Please review the changes first.

Checklist

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

cc @awslabs/raf-reviewer @comaniac

@zhouyuan1119 zhouyuan1119 changed the title [Remat][Bugfix] Enhance the rematerialization pass to handle nested tuples (#3) [Remat][Bugfix] Enhance the rematerialization pass to handle nested tuples Apr 14, 2022
Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

The change LGTM.

src/pass/liveness_analysis.cc Show resolved Hide resolved
Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM. Please remove the LOG

src/pass/rematerialization.cc Outdated Show resolved Hide resolved
@comaniac comaniac merged commit 3f51010 into awslabs:main Apr 17, 2022
@comaniac
Copy link
Contributor

Thanks @zhouyuan1119

@zhouyuan1119 zhouyuan1119 deleted the remat_fix branch April 18, 2022 17:13
Sign up for free to 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.

2 participants