Allow nested transformer block names for quantization, lora targeting, quantizing

This commit is contained in:
Jaret Burkett
2026-06-13 14:33:16 -06:00
parent 17c9279828
commit c8cd78b1a4
4 changed files with 20 additions and 4 deletions

View File

@@ -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(