Skip to content

Commit 7a2c375

Browse files
authored
fix gptq quantization condition (#2416)
* fix gptq quantization condition Signed-off-by: jiqing-feng <jiqing.feng@intel.com> * revert useless change Signed-off-by: jiqing-feng <jiqing.feng@intel.com> --------- Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
1 parent cebb682 commit 7a2c375

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

optimum/gptq/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ def get_layers(module: nn.Module, layers=[Conv1D, nn.Conv2d, nn.Linear], prefix:
4747
`Dict[str,Union[Conv1D, nn.Conv2d, nn.Linear]]`: Mapping of the name of the layer and the actual layer
4848
"""
4949
for layer in layers:
50-
if isinstance(module, layer):
50+
# Use exact type check for nn.Linear to skip subclasses with custom forward (e.g., MoE routers)
51+
if layer is nn.Linear:
52+
if type(module) is nn.Linear:
53+
if prefix is not None:
54+
if name.startswith(prefix):
55+
return {name: module}
56+
else:
57+
return {name: module}
58+
elif isinstance(module, layer):
5159
if prefix is not None:
5260
if name.startswith(prefix):
5361
return {name: module}

0 commit comments

Comments
 (0)