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.
This commit is contained in:
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user