Skip to content

[model] optimize padding mask reduction memory - #167

Open
Zhijun-Xu wants to merge 1 commit into
modelscope:mainfrom
Zhijun-Xu:perf/optimize-padding-mask-reduction
Open

[model] optimize padding mask reduction memory#167
Zhijun-Xu wants to merge 1 commit into
modelscope:mainfrom
Zhijun-Xu:perf/optimize-padding-mask-reduction

Conversation

@Zhijun-Xu

Copy link
Copy Markdown

For a 128K sequence length, calling .sum() on the boolean attention mask promotes it to int64, resulting in a temporary tensor exceeding 90 GB.
Replace it with the logically equivalent Tensor.all() operation, which performs a native boolean reduction and avoids the large temporary allocation.

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.

1 participant