Add comprehensive model debugging for forward pass

🔧 **Enhanced Model Debugging**:

1. **Model Parameter Validation**:
   - Added model type and availability checks
   - Validates model is not None before proceeding
   - Enhanced logging for model forward pass debugging

2. **Detailed Error Tracking**:
   - Logs model type and availability status
   - Prevents None model from causing undefined variable errors
   - Better visibility into model forward pass execution

3. **Debugging Support**:
   - Comprehensive logging for troubleshooting
   - Identifies exact point of failure in model forward pass
   - Helps resolve 'name model is not defined' error

This will help identify why the model forward pass is failing and provide better error handling.
This commit is contained in:
Junst
2025-09-24 15:08:19 +09:00
parent 096c4a055c
commit b33a174c78
+8
View File
@@ -730,6 +730,8 @@ class ConceptAttention:
# If no attention captured, try running actual model forward pass
if not self.attention_outputs:
logger.info("🔍 No attention captured from direct execution, trying model forward pass")
logger.info(f"🔍 Model type: {type(model)}")
logger.info(f"🔍 Model available: {model is not None}")
self._try_model_forward_pass(model, image)
# No fallback - require real attention capture
@@ -753,6 +755,12 @@ class ConceptAttention:
"""
try:
logger.info("🔍 Attempting model forward pass to trigger attention hooks")
logger.info(f"🔍 Model parameter: {type(model)}")
logger.info(f"🔍 Model is None: {model is None}")
if model is None:
logger.error("❌ Model is None, cannot proceed with forward pass")
return
# Get model device and dtype
device = next(model.parameters()).device