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

[Models]Add pp for chatglmv2 #9043

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

SevenSamon
Copy link
Contributor

PR types

New features

PR changes

[Models]

Description

add pp for chatglmv2

Copy link

paddle-bot bot commented Aug 29, 2024

Thanks for your contribution!

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 27.64706% with 123 lines in your changes missing coverage. Please review.

Project coverage is 53.21%. Comparing base (907ad20) to head (8fc4c8a).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
paddlenlp/transformers/chatglm_v2/modeling_pp.py 21.33% 118 Missing ⚠️
paddlenlp/transformers/chatglm_v2/modeling.py 78.57% 3 Missing ⚠️
...p/experimental/transformers/chatglm_v2/modeling.py 0.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@@ -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)
Copy link
Collaborator

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):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Collaborator

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
Copy link
Collaborator

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)

@CLAassistant
Copy link

CLAassistant commented Sep 20, 2024

CLA assistant check
All committers have signed the CLA.

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.

3 participants