From 608ea8d5d16929b93cd46bd3a2e9a977ab8c6845 Mon Sep 17 00:00:00 2001 From: Junst Date: Sun, 21 Sep 2025 18:57:03 +0900 Subject: [PATCH] Fix syntax error in concept_attention.py - Fixed missing try block closure that caused SyntaxError - Properly indented for loop inside try block - Corrected exception handling structure - Resolved 'expected except or finally block' error The hook system should now load properly without syntax errors. --- concept_attention.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/concept_attention.py b/concept_attention.py index 97c48b3..e7353da 100644 --- a/concept_attention.py +++ b/concept_attention.py @@ -476,9 +476,9 @@ class ConceptAttentionProcessor: if hasattr(self.concept_attention, 'attention_hooks') and self.concept_attention.attention_hooks: logger.info(f"Found {len(self.concept_attention.attention_hooks)} registered hooks") - # Try to find the modules that have hooks and call them directly - for name, module in actual_model.named_modules(): - if any(keyword in name.lower() for keyword in ['attention', 'attn', 'query', 'key', 'value', 'proj']): + # Try to find the modules that have hooks and call them directly + for name, module in actual_model.named_modules(): + if any(keyword in name.lower() for keyword in ['attention', 'attn', 'query', 'key', 'value', 'proj']): # Check if this module has a hook if hasattr(module, '_forward_hooks') and module._forward_hooks: logger.info(f"Module {name} has {len(module._forward_hooks)} hooks") @@ -504,7 +504,7 @@ class ConceptAttentionProcessor: except Exception as hook_error: logger.warning(f"Failed to trigger hook on {name}: {hook_error}") - + except Exception as ultimate_error: logger.warning(f"Ultimate hook triggering failed: {ultimate_error}")