Allow nested transformer block names for quantization, lora targeting, quantizing
This commit is contained in:
1 parent
17c9279828
commit
c8cd78b1a4
4 files changed
+20
-4
No files matched your search
@@ -297,7 +297,13 @@ def quantize_model(
|
||||
all_blocks: List[torch.nn.Module] = []
|
||||
transformer_block_names = base_model.get_transformer_block_names()
|
||||
for name in transformer_block_names:
|
||||
block_list = getattr(model_to_quantize, name, None)
|
||||
# name may be a dotted path for models that nest their blocks
|
||||
# (e.g. hidream_o1's "model.language_model.layers").
|
||||
block_list = model_to_quantize
|
||||
for part in name.split('.'):
|
||||
block_list = getattr(block_list, part, None)
|
||||
if block_list is None:
|
||||
break
|
||||
if block_list is not None:
|
||||
all_blocks += list(block_list)
|
||||
base_model.print_and_status_update(
|
||||
|
||||
Reference in new issue
Block a user