Download tests/test_fixed_layer.py from TRuCAL-Labs/TRuCAL: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/datasets/TRuCAL-Labs/TRuCAL/resolve/main/tests/test_fixed_layer.py
- Command line
-
hf download hf://datasets/TRuCAL-Labs/TRuCAL/tests/test_fixed_layer.py
-
curl -L -o test_fixed_layer.py https://huggingface.co/datasets/TRuCAL-Labs/TRuCAL/resolve/main/tests/test_fixed_layer.py
1.93 kB
| import torch | |
| from components.tiny_confessional_layer_fixed import TinyConfessionalLayer | |
| def test_fixed_layer(): | |
| """Test the fixed TinyConfessionalLayer with various input shapes.""" | |
| print("🧪 Testing TinyConfessionalLayer with shape safety...") | |
| # Test cases with different input shapes | |
| test_cases = [ | |
| (1, 10, 256), # Standard input | |
| (2, 8, 512), # Different batch/seq | |
| (4, 20, 128), # Different dimensions | |
| (1, 5, 768), # Larger feature dimension | |
| (3, 3, 3), # Very small dimensions | |
| ] | |
| for batch, seq, d_model in test_cases: | |
| print(f"\nTesting: batch={batch}, seq={seq}, d_model={d_model}") | |
| try: | |
| # Create model with default d_model=256 | |
| model = TinyConfessionalLayer( | |
| d_model=256, # Fixed internal dimension | |
| enable_ambient=False, # Disable ambient for simpler testing | |
| enable_windsurf=False # Disable windsurf for now | |
| ) | |
| # Create random input | |
| x = torch.randn(batch, seq, d_model) | |
| # Run forward pass | |
| out, metadata = model(x, audit_mode=True) | |
| # Check output shape | |
| expected_shape = (batch, seq, 256) # Should match model's d_model | |
| assert out.shape == expected_shape, \ | |
| f"Expected shape {expected_shape}, got {out.shape}" | |
| print(f"✅ Success! Input: {x.shape} -> Output: {out.shape}") | |
| print(f" Cycles: {metadata['cycles_run']}, " | |
| f"Shape fixes: {metadata.get('shape_issues_resolved', 0)}") | |
| except Exception as e: | |
| print(f"❌ Test failed: {str(e)}") | |
| import traceback | |
| traceback.print_exc() | |
| if __name__ == "__main__": | |
| test_fixed_layer() | |
| print("\n🎉 All tests completed!") | |