-
Notifications
You must be signed in to change notification settings - Fork 188
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
Gemlite fixes #1432
base: main
Are you sure you want to change the base?
Gemlite fixes #1432
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
from torchao.dtypes.utils import Layout, is_device | ||
from torchao.quantization.quant_primitives import quantize_affine | ||
from torchao.utils import fill_defaults | ||
import warnings | ||
|
||
aten = torch.ops.aten | ||
|
||
|
@@ -76,6 +77,14 @@ def apply_gemlite_quant( | |
out_features, in_features = weight.shape | ||
group_size = in_features if group_size is None else group_size | ||
|
||
if in_features % 128 != 0 and out_features % 128 != 0: | ||
warnings.simplefilter("once", UserWarning) | ||
warnings.warn( | ||
"Gemlite only works for layers with in_features or out_features divisible by 128, " | ||
+ "some layers have been skipped", UserWarning | ||
) | ||
return weight | ||
|
||
quant_kwargs = get_gemlite_quant_kwargs(bit_width, group_size) | ||
|
||
layout = GemlitePackedLayout( | ||
|
@@ -173,6 +182,10 @@ def from_plain( | |
exhaustive=False, | ||
use_cuda_graph=False, | ||
) | ||
if _layout.group_size == None and _layout.bit_width == 4: | ||
from gemlite.core import GEMLITE_ACC_DTYPE | ||
from gemlite.dtypes import DType | ||
GEMLITE_ACC_DTYPE[DType.FP16] = DType.FP32 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will only work when all the layers use the same group_size, which is ok for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this manually, it works in all cases even when there are different group sizes. |
||
|
||
out_features, in_features = int_data.shape | ||
input_dtype, output_dtype = DType.FP16, DType.FP16 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why these changes? is this some rebase issue