Skip to content

Allocate and Deallocate HostIr insertion in FusionKernelRuntime #4329

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

nsarka
Copy link
Member

@nsarka nsarka commented Apr 28, 2025

Follow-up PR to #4286. The PR will insert allocate ops for every LaunchKernel output, and also insert a Deallocate right after the last use of every input expr in the Hostir container. It adds a test to check the number of Deallocate ops and the max memory usage is correct for an example fusion as well.

@nsarka nsarka requested a review from wujingyue April 28, 2025 20:57
Copy link
Collaborator

@wujingyue wujingyue left a comment

Choose a reason for hiding this comment

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

Can you separate this into two PRs, the first one being a rollback of #4303 (with fixes of course) and the second being insert deallocations?

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/getting-started/helping-others-review-your-changes#write-small-pull-requests

@nsarka nsarka force-pushed the nsarka/hostir-integration-3 branch 3 times, most recently from e6d02e1 to 3fce074 Compare April 29, 2025 19:59
@nsarka nsarka requested a review from wujingyue April 30, 2025 15:36
output_tensor, info.tv, expr_eval);
info.shape_info.allocation_sizes = alloc_sizes;
info.shape_info.allocation_strides = alloc_strides;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not 100% sure whether this may have any unintended side effects. I will take a look into it

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @jjsjann123 do you recall why it was problematic for pre-allocated outputs to have allocation domains?

@nsarka nsarka force-pushed the nsarka/hostir-integration-3 branch from 848f41f to d0d169e Compare April 30, 2025 15:40
@nsarka
Copy link
Member Author

nsarka commented Apr 30, 2025

!test

1 similar comment
@nsarka
Copy link
Member Author

nsarka commented Apr 30, 2025

!test

@nsarka nsarka changed the title Deallocate HostIr Op, test, and automatic insertion in FusionKernelRuntime Automatic Allocate and Deallocate HostIr insertion in FusionKernelRuntime Apr 30, 2025
@nsarka nsarka changed the title Automatic Allocate and Deallocate HostIr insertion in FusionKernelRuntime Allocate and Deallocate HostIr insertion in FusionKernelRuntime Apr 30, 2025
Copy link
Collaborator

@wujingyue wujingyue left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good overall. I'm also unsure about the change executor.cpp. So cc'ed Jie

output_tensor, info.tv, expr_eval);
info.shape_info.allocation_sizes = alloc_sizes;
info.shape_info.allocation_strides = alloc_strides;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @jjsjann123 do you recall why it was problematic for pre-allocated outputs to have allocation domains?

@nsarka nsarka force-pushed the nsarka/hostir-integration-3 branch from 507b9b1 to a103e0b Compare May 1, 2025 13:56
@nsarka nsarka requested a review from wujingyue May 1, 2025 17:32
Copy link
Collaborator

@wujingyue wujingyue left a comment

Choose a reason for hiding this comment

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

LGTM with comments!

The PR description seems outdated. Please fix that as well.

@nsarka
Copy link
Member Author

nsarka commented May 1, 2025

!test

1 similar comment
@nsarka
Copy link
Member Author

nsarka commented May 1, 2025

!test

@nsarka
Copy link
Member Author

nsarka commented May 1, 2025

!test

@nsarka nsarka force-pushed the nsarka/hostir-integration-3 branch from d02cdb5 to c0848ed Compare May 2, 2025 13:42
@nsarka
Copy link
Member Author

nsarka commented May 2, 2025

!test

@nsarka nsarka force-pushed the nsarka/hostir-integration-3 branch from 5d8db2d to 96427a0 Compare May 2, 2025 20:52
@nsarka
Copy link
Member Author

nsarka commented May 2, 2025

!test

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