Skip to content

[Relax] Eager free original weights in transform_params - #16674

Merged
tqchen merged 2 commits into
apache:mainfrom
vinx13:feat/eager-consume
Mar 6, 2024
Merged

tqchen merged 2 commits into
apache:mainfrom
vinx13:feat/eager-consume

Conversation

@vinx13

@vinx13 vinx13 commented Mar 5, 2024

Copy link
Copy Markdown
Member

This updates LiftTransformParams to always free original weight in the bundled weights tuple. This prevents the issue that transform_params consumes memory with double weight size. See discussion https://discuss.tvm.apache.org/t/inplacetransformparams/16323.

cc @tqchen @MasterJH5574 @Lunderberg

Comment thread src/relax/transform/lift_transform_params.cc Outdated
@Lunderberg

Copy link
Copy Markdown
Contributor

Any idea why the KillAfterLastUse pass isn’t already handling this case? It seems like it shouldn’t require special handling in LiftTransformParams.

@tqchen

tqchen commented Mar 5, 2024

Copy link
Copy Markdown
Member

@Lunderberg in this case we are also killing the elements within tuple which is not covered by killafter use

@Lunderberg

Copy link
Copy Markdown
Contributor

Ah, thank you, and that makes sense. That would also explain why the increased footprint isn’t seen when using LazyTransformParams, since the tuple doesn’t exist as a parameter.

If I understand correctly, we could achieve a similar effect by unpacking the entire tuple on its first use, though that could be less robust to later lowering passes. Since we have the in-place updates, it makes sense to use them, and I like the change.

@tqchen
tqchen merged commit a0f57a0 into apache:main Mar 6, 2024
Lunderberg pushed a commit to Lunderberg/tvm that referenced this pull request Mar 12, 2024
* [Relax] Eager free original weights in transform_params

* address comments
thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
* [Relax] Eager free original weights in transform_params

* address comments
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.

3 participants