Update gemma.py
This commit is contained in:
parent
cd479b4374
commit
9c565580fb
1 changed files with 9 additions and 9 deletions
|
|
@ -89,7 +89,7 @@ def GemmaDecoderLayer_fast_forward(
|
|||
hidden_states += residual
|
||||
else:
|
||||
residual = hidden_states
|
||||
hidden_states = self.input_layernorm(hidden_states)
|
||||
hidden_states = fast_rms_layernorm(self.input_layernorm, hidden_states)
|
||||
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
||||
hidden_states=hidden_states,
|
||||
causal_mask=causal_mask,
|
||||
|
|
@ -104,7 +104,7 @@ def GemmaDecoderLayer_fast_forward(
|
|||
|
||||
# Fully Connected
|
||||
residual = hidden_states
|
||||
hidden_states = self.post_attention_layernorm(hidden_states)
|
||||
hidden_states = fast_rms_layernorm(self.post_attention_layernorm, hidden_states)
|
||||
hidden_states = self.mlp(hidden_states)
|
||||
hidden_states = residual + hidden_states
|
||||
pass
|
||||
|
|
@ -350,7 +350,7 @@ def GemmaModel_fast_forward(
|
|||
all_self_attns += (layer_outputs[1],)
|
||||
pass
|
||||
|
||||
hidden_states = self.norm(hidden_states)
|
||||
hidden_states = fast_rms_layernorm(self.norm, hidden_states)
|
||||
|
||||
# add hidden states from the last decoder layer
|
||||
if output_hidden_states:
|
||||
|
|
@ -531,12 +531,12 @@ class FastGemmaModel(FastLlamaModel):
|
|||
pass
|
||||
|
||||
print("Unsloth: Patching Gemma RMS Layernorm + 1")
|
||||
# for name, module in model.named_modules():
|
||||
# if isinstance(module, GemmaRMSNorm):
|
||||
# module.weight += 1.0 # return output * (1 + self.weight)
|
||||
# if not hasattr(module, "variance_epsilon"):
|
||||
# module.variance_epsilon = module.eps # Gemma doesn't use variance_epsilon
|
||||
# pass
|
||||
for name, module in model.named_modules():
|
||||
if isinstance(module, GemmaRMSNorm):
|
||||
module.weight += 1.0 # return output * (1 + self.weight)
|
||||
if not hasattr(module, "variance_epsilon"):
|
||||
module.variance_epsilon = module.eps # Gemma doesn't use variance_epsilon
|
||||
pass
|
||||
|
||||
# Clear deleted GPU items
|
||||
import gc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue