-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Models]Add pp for chatglmv2 #9043
base: develop
Are you sure you want to change the base?
Conversation
…PaddleNLP into add_pp_for_chatglmv2
Thanks for your contribution! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9043 +/- ##
===========================================
- Coverage 53.26% 53.21% -0.05%
===========================================
Files 652 654 +2
Lines 105615 105775 +160
===========================================
+ Hits 56254 56293 +39
- Misses 49361 49482 +121 ☔ View full report in Codecov by Sentry. |
@@ -185,7 +185,7 @@ def __init__(self, config: ChatGLMv2Config, empty_init=True): | |||
if self.post_layer_norm: | |||
LayerNormFunc = RMSNorm if config.rmsnorm else nn.LayerNorm | |||
# Final layer norm before output. | |||
self.final_layernorm = LayerNormFunc(config.hidden_size, epsilon=config.layernorm_epsilon) | |||
self.final_layernorm = LayerNormFunc(config.hidden_size, epsilon=config.layernorm_epsilon, config=config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need change this?
@@ -97,7 +150,7 @@ def apply_rotary_pos_emb(x: paddle.Tensor, rope_cache: paddle.Tensor) -> paddle. | |||
|
|||
|
|||
class RMSNorm(nn.Layer): | |||
def __init__(self, hidden_size, epsilon=None): | |||
def __init__(self, hidden_size, config: ChatGLMv2Config, epsilon=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, hidden_size, config: ChatGLMv2Config, epsilon=None): | |
def __init__(self, config: ChatGLMv2Config): | |
hidden_size = config.hidden_size | |
eps = config.eps | |
@@ -185,7 +185,7 @@ def __init__(self, config: ChatGLMv2Config, empty_init=True): | |||
if self.post_layer_norm: | |||
LayerNormFunc = RMSNorm if config.rmsnorm else nn.LayerNorm | |||
# Final layer norm before output. | |||
self.final_layernorm = LayerNormFunc(config.hidden_size, epsilon=config.layernorm_epsilon) | |||
self.final_layernorm = LayerNormFunc(config.hidden_size, epsilon=config.layernorm_epsilon, config=config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if config.rmsnorm:
RMSNorm(config)
else:
nn.LayerNorm(xxx,xx)
|
||
# Recompute defaults to False and is controlled by Trainer | ||
self.enable_recompute = False | ||
self.config = config | ||
self.fp32_residual_connection = config.fp32_residual_connection | ||
|
||
LayerNormFunc = RMSNorm if config.rmsnorm else nn.LayerNorm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class LayerNorm(nn.LayerNorm):
def __init__(self, config):
self.config = config
super().__init__(config.hidde_size, xx)
PR types
New features
PR changes
[Models]
Description
add pp for chatglmv2