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

fix(model.py): align_preciion_in_norm_layer #182

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

Conversation

gyt1145028706
Copy link
Contributor

在 Norm Layer 中添加 set_norm_precision_to_float32 函数,在 model 初始化后调用,将 Norm Layer 的权重转成 float32

@@ -80,6 +80,9 @@ def __init__(self, dim=None, dtype=torch.float, eps=1e-5, weight=None):
)
self.eps = eps

def set_norm_precision_to_float32(self):
self.weight.data = self.weight.data.to(torch.float32)

Copy link
Collaborator

Choose a reason for hiding this comment

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

llama里hidden_states和self.weight相乘之后是fp32,应该需要转回16位才能传给下一层,否则会报dtype不match的错。可以检查一下别的模型会不会有这个问题。

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