Update custom_generate/generate.py
Browse files
custom_generate/generate.py
CHANGED
|
@@ -43,6 +43,7 @@ from transformers.modeling_utils import PreTrainedModel
|
|
| 43 |
from .functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 44 |
from .monkey_patching_utils import monkey_patching
|
| 45 |
from .sep_cache_utils import SepCache
|
|
|
|
| 46 |
# except :
|
| 47 |
# from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 48 |
# from ..monkey_patching_utils import monkey_patching
|
|
@@ -120,9 +121,9 @@ def generate(model,
|
|
| 120 |
print(f"__file__: {__file__}")
|
| 121 |
print(f"os.path.abspath(__file__): {os.path.abspath(__file__)}")
|
| 122 |
|
| 123 |
-
from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 124 |
-
from ..monkey_patching_utils import monkey_patching
|
| 125 |
-
from ..sep_cache_utils import SepCache
|
| 126 |
|
| 127 |
|
| 128 |
|
|
@@ -228,7 +229,7 @@ def generate(model,
|
|
| 228 |
"""
|
| 229 |
|
| 230 |
# 0. Monkey Patching for the `update` function of `SepCache`
|
| 231 |
-
model_layers = monkey_patching(model, model_atten_forward=llama_atten_forward, verbose=monkey_patch_verbose)
|
| 232 |
|
| 233 |
# 1. General sanity checks
|
| 234 |
# 1.a. A few arguments are not allowed, especially arguments that control caches.
|
|
|
|
| 43 |
from .functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 44 |
from .monkey_patching_utils import monkey_patching
|
| 45 |
from .sep_cache_utils import SepCache
|
| 46 |
+
|
| 47 |
# except :
|
| 48 |
# from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 49 |
# from ..monkey_patching_utils import monkey_patching
|
|
|
|
| 121 |
print(f"__file__: {__file__}")
|
| 122 |
print(f"os.path.abspath(__file__): {os.path.abspath(__file__)}")
|
| 123 |
|
| 124 |
+
# from ..functions_2_patch import _validate_model_kwargs, llama_atten_forward
|
| 125 |
+
# from ..monkey_patching_utils import monkey_patching
|
| 126 |
+
# from ..sep_cache_utils import SepCache
|
| 127 |
|
| 128 |
|
| 129 |
|
|
|
|
| 229 |
"""
|
| 230 |
|
| 231 |
# 0. Monkey Patching for the `update` function of `SepCache`
|
| 232 |
+
# model_layers = monkey_patching(model, model_atten_forward=llama_atten_forward, verbose=monkey_patch_verbose)
|
| 233 |
|
| 234 |
# 1. General sanity checks
|
| 235 |
# 1.a. A few arguments are not allowed, especially arguments that control caches.
|