Skip to content

Commit

Permalink
add gc collect in packing
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhuach21 committed Feb 13, 2025
1 parent edc2b03 commit 8e39e07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion auto_round/export/export_to_autogptq/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import gc

# MIT License
#
Expand Down Expand Up @@ -116,6 +116,8 @@ def pack_layer(name, model, layer_config, backend, pbar):
qlayer.pack(layer, scale, zero, None)
qlayer.to(device)
pbar.update(1)
if pbar.n%50==0:
gc.collect()


def save_quantized_as_autogptq(output_dir, inplace=True, backend="auto_gptq:exllamav2",
Expand Down
3 changes: 3 additions & 0 deletions auto_round/export/export_to_autoround/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def pack_layer(name, model, layer_config, backend, pbar):
set_module(model, name, qlayer)
clear_memory()
pbar.update(1)
if pbar.n%50==0:
import gc
gc.collect()


def save_quantized_as_autoround(output_dir, inplace=True, backend="auto_round:exllamav2", **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions auto_round/export/export_to_awq/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def pack_layer(name, model, layer_config, backend, pbar):
)
set_module(model, name, q_linear)
pbar.update(1)
if pbar.n % 50 == 0:
import gc
gc.collect()


def save_quantized_as_autoawq(output_dir, inplace=True, **kwargs):
Expand Down

0 comments on commit 8e39e07

Please sign in to comment.