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: Mamba2 norm_before_gate usage #32686

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/transformers/models/mamba2/configuration_mamba2.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ class Mamba2Config(PretrainedConfig):
Whether or not to rescale `out_proj` weights when initializing.
use_cache (`bool`, *optional*, defaults to `True`):
Whether or not the cache should be used.
norm_before_gate (`bool`, *optional*, defaults to `True`):
Option of cuda kernels -whether to normalize before the gate or not.
rms_norm (`bool`, *optional*, defaults to `True`):
Whether to use RMS norm or not.
chunk_size (`int`, *optional*, defaults to 256):
Expand Down Expand Up @@ -137,7 +135,6 @@ def __init__(
time_step_limit=(0.0, float("inf")),
rescale_prenorm_residual=False,
use_cache=True,
norm_before_gate=True,
rms_norm=True,
chunk_size=256,
tie_word_embeddings=False,
Expand Down Expand Up @@ -168,7 +165,6 @@ def __init__(
self.n_groups = n_groups
self.num_heads = num_heads
self.head_dim = head_dim
self.norm_before_gate = norm_before_gate
self.rms_norm = rms_norm
self.state_size = state_size
self.chunk_size = chunk_size
Expand Down
3 changes: 1 addition & 2 deletions src/transformers/models/mamba2/modeling_mamba2.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def __init__(self, config: Mamba2Config, layer_idx: int):
self.activation = config.hidden_act
self.act = ACT2FN[config.hidden_act]

self.norm_before_gate = config.norm_before_gate
self.layer_norm_epsilon = config.layer_norm_epsilon
self.rms_norm = config.rms_norm

Expand Down Expand Up @@ -347,7 +346,7 @@ def cuda_kernels_forward(
outproj_bias=self.out_proj.bias,
headdim=self.head_dim,
ngroups=self.n_groups,
norm_before_gate=self.norm_before_gate,
norm_before_gate=False,
return_final_states=True,
**dt_limit_kwargs,
)
Expand Down
Loading