This commit is contained in:
Daniel Han 2025-01-16 01:22:13 -08:00
commit 69b09d80c8
2 changed files with 4 additions and 8 deletions

View file

@ -799,9 +799,7 @@ def patch_linear_scaling(
f"from typing import Union, Optional, List, Any, Callable, Tuple\n"\
f"from {model_filepath} import logger, "\
f"{model_name.title()}Attention, {model_name.title()}Config"
print(exec_code)
print(inspect.getsource(attention_module.__init__))
try:
function = inspect.getsource(attention_module.__init__)
except:
@ -845,12 +843,12 @@ def patch_linear_scaling(
"self.rotary_emb = .+?\)", function,
flags = re.DOTALL | re.MULTILINE,
)
if len(rotary_emb) == 0: return None, function
if len(rotary_emb) == 0:
return None, exec_code + "\n\n" + function
rotary_emb = rotary_emb[0]
function = function.replace(rotary_emb, fix_rope_function, 1)
function = exec_code + "\n\n" + function
print("###########")
print(exec_code)
return init_name, function
pass

View file

@ -305,9 +305,7 @@ class FastMistralModel(FastLlamaModel):
)
# Just for Mistral Nemo models!
if function is not None:
print(function)
function = patch_mistral_nemo_attention(function)
print(function)
# if True:#init_name is not None:
exec(function, globals())
MistralAttention.__init__ = eval(init_name)