File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
src/llmcompressor/entrypoints Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 14
14
from llmcompressor .entrypoints .utils import post_process , pre_process
15
15
from llmcompressor .pipelines import CalibrationPipeline
16
16
17
+ from accelerate .hooks import remove_hook_from_module
18
+
17
19
__all__ = ["Oneshot" , "oneshot" ]
18
20
19
21
@@ -130,6 +132,8 @@ def __init__(
130
132
# TODO: consider renaming function similar to "offload_dispatch_model"
131
133
# TODO: modify function to remove any hooks if they already exist (making
132
134
# sure to move to cpu when removing hook
135
+ # TODO: remove hook in util
136
+ remove_hook_from_module (model_args .model , recurse = True )
133
137
force_cpu_offload (model_args .model , model_args .oneshot_device )
134
138
else :
135
139
logger .warning ("CUDA is not available! Compressing model on CPU instead" )
Original file line number Diff line number Diff line change 27
27
)
28
28
from llmcompressor .typing import Processor
29
29
from llmcompressor .utils .fsdp .helpers import is_fsdp_model
30
+ from accelerate .hooks import remove_hook_from_module
30
31
31
32
32
33
def pre_process (model_args : "ModelArguments" ):
@@ -105,6 +106,9 @@ def post_process(
105
106
"Ex. `oneshot(..., output_dir=...)`"
106
107
)
107
108
109
+ # Remove any existing hooks (maybe added by oneshot sequential onloading)
110
+ remove_hook_from_module (model_args .model , recurse = True )
111
+
108
112
# Reset the one-time-use session upon completion
109
113
if recipe_args is not None and recipe_args .clear_sparse_session :
110
114
reset_session ()
You can’t perform that action at this time.
0 commit comments