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

change llama/modeling.py to opt npu performence #8342

Merged
merged 7 commits into from
Apr 30, 2024
Merged

change llama/modeling.py to opt npu performence #8342

merged 7 commits into from
Apr 30, 2024

Conversation

Galaxy1458
Copy link
Contributor

@Galaxy1458 Galaxy1458 commented Apr 28, 2024

PR types

Performance optimization

PR changes

Models

Description

优化NPU下跑llama模型时使用is_casual_mask 对ppt, lora ,sft策略选择问题

Copy link

paddle-bot bot commented Apr 28, 2024

Thanks for your contribution!

Copy link
Contributor

@SylarTiaNII SylarTiaNII left a comment

Choose a reason for hiding this comment

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

LGTM

# masked_lm_loss = masked_lm_loss[masked_lm_loss > 0]
# loss = paddle.mean(masked_lm_loss)
binary_sequence = paddle.where(masked_lm_loss > 0, paddle.ones_like(masked_lm_loss), paddle.zeros_like(masked_lm_loss))
loss = paddle.sum(masked_lm_loss * binary_sequence) / paddle.sum(binary_sequence)
Copy link
Collaborator

@wawltor wawltor Apr 29, 2024

Choose a reason for hiding this comment

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

paddle.sum(binary_sequence) 中binary_sequence有可能全为0,导致sum后0;这里loss会有异常

之前的业务遇到过这个问题

Copy link
Collaborator

Choose a reason for hiding this comment

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

同时对GPU性能的影响是什么

@wawltor wawltor requested a review from ZHUI April 30, 2024 05:06
Copy link
Collaborator

@ZHUI ZHUI left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit 1c781d8 into PaddlePaddle:develop Apr 30, 2024
6 of 9 checks passed
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