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

[NNPA] Memory reduction of stickified constant by stickifying at file writing #2917

Merged
merged 75 commits into from
Nov 5, 2024

Conversation

imaihal
Copy link
Collaborator

@imaihal imaihal commented Aug 26, 2024

This PR reduces memory usage for NNPA compilation. Current main branch creates stickified data in ZHighConstPropagationPass and keeps the data until compilation finish. This PR sets original data, not stickified data, in ZHighConstPropagationPass. Then, in the KrnlToLLVMPass, stickfied data is created and stored in the file, and deleted after writing into the file. 

image

@imaihal imaihal changed the title [NNPA] Memory reduction by running stickification at file wrting [NNPA] Memory reduction of stickified constant by stickifying at file writing Aug 26, 2024
@imaihal
Copy link
Collaborator Author

imaihal commented Sep 11, 2024

@jenkins-droid test this please.

Signed-off-by: Haruki Imai <[email protected]>
"The stickified tensor's buffer size and MemRef's size mismatched");

// Create a KrnlGlobalOp.
KrnlGlobalOp constantGlobal =
Copy link
Collaborator

@chentong319 chentong319 Oct 29, 2024

Choose a reason for hiding this comment

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

Keep the previous implementation with KrnlGlobalOp in comment or if false branch, if you do not want to create an option to control the choice. You can define an option '--disable-krnl-constant-to-file' with default value of 'false'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. Is this because we may reuse the previous implementation in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I created directive NNPA_ZHIGH_STICKIFIEDCONST_GEN to keep the original implementation. Currently commented out, but I confirmed it works when enabling this code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, we may reuse or compare the original implementation.

@imaihal
Copy link
Collaborator Author

imaihal commented Oct 31, 2024

Could you review again?

@AlexandreEichenberger
Copy link
Collaborator

@chentong319 Do you mind reviewing it? You have been very involved with this PR. Thanks

Copy link
Collaborator

@chentong319 chentong319 left a comment

Choose a reason for hiding this comment

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

LGTM!

@imaihal
Copy link
Collaborator Author

imaihal commented Nov 5, 2024

@jenkins-droid test this please.

chentong319
chentong319 approved these changes Nov 5, 2024
@imaihal imaihal merged commit 33b466e into onnx:main Nov 5, 2024
7 checks passed
@imaihal imaihal deleted the mem_reduction_stickified branch November 5, 2024 14:48
@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #15951 [push] [NNPA] Memory reduction ... started at 09:49

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #15948 [push] [NNPA] Memory reduction ... started at 08:49

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #14978 [push] [NNPA] Memory reduction ... started at 10:03

@jenkins-droid
Copy link
Collaborator

Jenkins Linux amd64 Build #15948 [push] [NNPA] Memory reduction ... passed after 1 hr 20 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux s390x Build #15951 [push] [NNPA] Memory reduction ... passed after 1 hr 24 min

@jenkins-droid
Copy link
Collaborator

Jenkins Linux ppc64le Build #14978 [push] [NNPA] Memory reduction ... passed after 2 hr 18 min

tungld added a commit to tungld/onnx-mlir that referenced this pull request Nov 13, 2024
… at file writing (onnx#2917)"

This reverts commit 33b466e.

Signed-off-by: Tung D. Le <[email protected]>
tungld added a commit to tungld/onnx-mlir that referenced this pull request Nov 18, 2024
tungld added a commit to tungld/onnx-mlir that referenced this pull request Nov 18, 2024
… at file writing (onnx#2917)"

This reverts commit 33b466e.

Signed-off-by: Tung D. Le <[email protected]>
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.

5 participants