Skip to content

Conversation

@gyt1145028706
Copy link
Contributor

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


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