@@ -154,13 +154,15 @@ def __init__(self, settings: Settings):
154154 # so we don't need to do anything manually.
155155
156156 print (f"* Transformer model with [bold]{ len (self .get_layers ())} [/] layers" )
157- print ( "* Abliterable components:" )
157+
158158 all_components = {}
159159 for layer_index in range (len (self .get_layers ())):
160160 for component , modules in self .get_layer_modules (layer_index ).items ():
161161 if component not in all_components :
162162 all_components [component ] = 0
163163 all_components [component ] += len (modules )
164+
165+ print ("* Abliterable components:" )
164166 for component , count in all_components .items ():
165167 print (f" * [bold]{ component } [/]: [bold]{ count } [/] modules total" )
166168
@@ -368,8 +370,8 @@ def try_add(component: str, module: Any):
368370 with suppress (Exception ):
369371 try_add ("attn.o_proj" , layer .self_attn .o_proj ) # ty:ignore[possibly-missing-attribute]
370372
371- # Qwen3.5 MoE hybrid layers use GatedDeltaNet (linear attention) instead
372- # of standard self-attention, so self_attn.o_proj doesn't exist on those layers.
373+ # Qwen3.5 MoE hybrid layers use GatedDeltaNet (linear attention) instead of
374+ # standard self-attention, so self_attn.o_proj doesn't exist on those layers.
373375 with suppress (Exception ):
374376 try_add ("attn.o_proj" , layer .linear_attn .out_proj ) # ty:ignore[possibly-missing-attribute]
375377
@@ -403,11 +405,13 @@ def try_add(component: str, module: Any):
403405 return modules
404406
405407 def get_abliterable_components (self ) -> list [str ]:
408+ components : set [str ] = set ()
409+
406410 # Scan all layers because hybrid models (e.g. Qwen3.5 MoE) have different
407411 # components on different layers (some have self_attn, others linear_attn).
408- components : set [str ] = set ()
409412 for layer_index in range (len (self .get_layers ())):
410413 components .update (self .get_layer_modules (layer_index ).keys ())
414+
411415 return sorted (components )
412416
413417 def abliterate (
@@ -744,9 +748,8 @@ def get_logprobs(self, prompts: list[Prompt]) -> Tensor:
744748 # The returned tensor has shape (prompt, token).
745749 logprobs = F .log_softmax (logits , dim = - 1 )
746750
747- del outputs
748-
749751 if self .settings .offload_outputs_to_cpu :
752+ del outputs , logits
750753 logprobs = logprobs .cpu ()
751754 empty_cache ()
752755
0 commit comments