Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

porting sq to autoround #199

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions auto_round/low_cpu_mem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,12 @@ def _layer_wise_to(module, name, device_or_dtype):
return module.ori_to(device_or_dtype)
elif len(module._modules) == 0:
# skip method type
if len(module._parameters) == 0 or module.weight.device.type != 'meta':
if len(module._parameters) == 0:
return module.ori_to(device_or_dtype)
else:
for n, _ in module.named_parameters():
for n, p in module.named_parameters():
if p.device.type != 'meta':
continue
param_name = name + "." + n
value = load_value(empty_model, param_name, empty_model.path)
dtype = None
Expand Down
4 changes: 2 additions & 2 deletions auto_round/quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(self, orig_layer, enable_minmax_tuning=True, device='cpu'):

weight_dtype = torch.float32
orig_layer_weight = self.orig_layer.weight if not hasattr(self.orig_layer, 'get_weight') \
else self.orig_layer.get_weight()
else self.orig_layer.get_weight().to(device)
self.value = torch.nn.Parameter(
reshape_tensor(
torch.zeros(self.orig_layer.weight.shape, device=self.device, dtype=weight_dtype),
Expand Down Expand Up @@ -285,7 +285,7 @@ def __init__(self, orig_layer, enable_minmax_tuning=True, device='cpu'):
weight_dtype = torch.float32
self.device = device
if hasattr(self.orig_layer, 'get_weight'):
self.weight_t = self.orig_layer.get_weight().t()
self.weight_t = self.orig_layer.get_weight().t().to(self.device)
else:
self.weight_t = self.orig_layer.weight.t()
self.weight_t = self.weight_t.to(self.device)
Expand Down
16 changes: 16 additions & 0 deletions auto_round/smooth_quant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to algorithm_ext

#
# Copyright (c) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
Loading
Loading