From e26da5e0e648bb285f896c9801849edfa8d20913 Mon Sep 17 00:00:00 2001 From: erm14254 <241810459+erm14254@users.noreply.github.com> Date: Wed, 11 Mar 2026 09:40:37 +0100 Subject: [PATCH] fix: display all abliterable components across layers (#215) * fix: display all abliterable components across layers The current code only displays abliterable components from layer 0, which is misleading for hybrid architectures like Qwen3.5 that use different attention types across layers (e.g., `linear_attn.out_proj` in some layers, `self_attn.o_proj` in others). This fix iterates through all layers to collect and display the complete set of abliterable components with accurate module counts. Before (Qwen3.5-27B): * attn.out_proj: 1 modules per layer * mlp.down_proj: 1 modules per layer After (Qwen3.5-27B): * attn.out_proj: 48 modules total * attn.o_proj: 16 modules total * mlp.down_proj: 64 modules total * Fix formatting --------- Co-authored-by: Lawfer12 --- src/heretic/model.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/heretic/model.py b/src/heretic/model.py index c751c99..0511d3b 100644 --- a/src/heretic/model.py +++ b/src/heretic/model.py @@ -151,10 +151,14 @@ class Model: print(f"* Transformer model with [bold]{len(self.get_layers())}[/] layers") print("* Abliterable components:") - for component, modules in self.get_layer_modules(0).items(): - print( - f" * [bold]{component}[/]: [bold]{len(modules)}[/] modules per layer" - ) + all_components = {} + for layer_index in range(len(self.get_layers())): + for component, modules in self.get_layer_modules(layer_index).items(): + if component not in all_components: + all_components[component] = 0 + all_components[component] += len(modules) + for component, count in all_components.items(): + print(f" * [bold]{component}[/]: [bold]{count}[/] modules total") def _apply_lora(self): # Guard against calling this method at the wrong time.