remove phi3 empty cache (#10997)
This commit is contained in:
parent
99255fe36e
commit
1b3c7a6928
1 changed files with 0 additions and 9 deletions
|
|
@ -188,13 +188,6 @@ def is_linear_module(module):
|
||||||
return result, (in_features, out_features, mp_group)
|
return result, (in_features, out_features, mp_group)
|
||||||
|
|
||||||
|
|
||||||
def empty_cache_post(module, input, output):
|
|
||||||
try:
|
|
||||||
torch.xpu.empty_cache()
|
|
||||||
except: # cpu
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def convert_gptq(module, awq=False, llm_awq=False, act_order=False):
|
def convert_gptq(module, awq=False, llm_awq=False, act_order=False):
|
||||||
from ipex_llm.transformers.low_bit_linear import get_block_size
|
from ipex_llm.transformers.low_bit_linear import get_block_size
|
||||||
Q4_1 = get_block_size("asym_int4")
|
Q4_1 = get_block_size("asym_int4")
|
||||||
|
|
@ -1524,8 +1517,6 @@ def _optimize_post(model, lightweight_bmm=False):
|
||||||
from ipex_llm.transformers.models.phi3 import model_forward_wrapper
|
from ipex_llm.transformers.models.phi3 import model_forward_wrapper
|
||||||
model_forward = model_forward_wrapper(module.Phi3Model.forward)
|
model_forward = model_forward_wrapper(module.Phi3Model.forward)
|
||||||
convert_forward(model, module.Phi3Model, model_forward)
|
convert_forward(model, module.Phi3Model, model_forward)
|
||||||
# Empty cache after the first attention to run long context.
|
|
||||||
model.model.layers[0].self_attn.register_forward_hook(empty_cache_post)
|
|
||||||
elif model.config.model_type == 'yuan':
|
elif model.config.model_type == 'yuan':
|
||||||
modeling_module_name = model.__class__.__module__
|
modeling_module_name = model.__class__.__module__
|
||||||
module = importlib.import_module(modeling_module_name)
|
module = importlib.import_module(modeling_module_name)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue