mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-06-02 21:30:52 -05:00
✅ Fix 12_compression: Move integration tests BEFORE testing, clean structure
CORRECTED PATTERN NOW: 1. ✅ Integration tests (test_compression_integration, test_comprehensive_compression_integration) - BEFORE ## 🧪 Module Testing 2. ✅ ## 🧪 Module Testing (markdown section) 3. ✅ STANDARDIZED MODULE TESTING (nbgrader cell) 4. ✅ if __name__ == '__main__' block with run_module_tests_auto 5. ✅ ## 🎯 Module Summary (immediately after, no code between) FIXES APPLIED: ✅ Moved both integration test functions from AFTER testing section to BEFORE it ✅ Removed duplicate integration test functions and markdown sections ✅ Cleaned up multiple run_module_tests_auto calls - now only one clean call ✅ Proper STANDARDIZED MODULE TESTING structure Module 12_compression now follows the exact pattern
This commit is contained in:
@@ -1656,26 +1656,6 @@ def test_unit_comprehensive_comparison():
|
||||
# Run the test
|
||||
test_comprehensive_comparison()
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
## 🧪 Module Testing
|
||||
|
||||
Time to test your implementation! This section uses TinyTorch's standardized testing framework to ensure your implementation works correctly.
|
||||
|
||||
**This testing section is locked** - it provides consistent feedback across all modules and cannot be modified.
|
||||
"""
|
||||
|
||||
# %% nbgrader={"grade": false, "grade_id": "standardized-testing", "locked": true, "schema_version": 3, "solution": false, "task": false}
|
||||
# =============================================================================
|
||||
# STANDARDIZED MODULE TESTING - DO NOT MODIFY
|
||||
# This cell is locked to ensure consistent testing across all TinyTorch modules
|
||||
# =============================================================================
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
## 🔬 Integration Test: Pruning a Sequential Model
|
||||
"""
|
||||
|
||||
# %%
|
||||
def test_compression_integration():
|
||||
"""Integration test for applying compression to a Sequential model."""
|
||||
@@ -1708,26 +1688,6 @@ def test_compression_integration():
|
||||
|
||||
print("✅ Integration Test Passed: Pruning correctly modified a layer in a Sequential model.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Unit tests
|
||||
test_compression_metrics()
|
||||
test_magnitude_pruning()
|
||||
test_quantization()
|
||||
test_distillation()
|
||||
test_structured_pruning()
|
||||
test_comprehensive_comparison()
|
||||
# Integration test
|
||||
test_compression_integration()
|
||||
|
||||
from tito.tools.testing import run_module_tests_auto
|
||||
# Automatically discover and run all tests in this module
|
||||
success = run_module_tests_auto("Compression")
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
## 🔬 Integration Test: Comprehensive Compression on a Sequential Model
|
||||
"""
|
||||
|
||||
# %%
|
||||
def test_comprehensive_compression_integration():
|
||||
"""
|
||||
@@ -1775,8 +1735,33 @@ def test_comprehensive_compression_integration():
|
||||
|
||||
print("✅ Integration Test Passed: Comprehensive compression successfully applied and verified.")
|
||||
|
||||
# %% [markdown]
|
||||
"""
|
||||
## 🧪 Module Testing
|
||||
|
||||
Time to test your implementation! This section uses TinyTorch's standardized testing framework to ensure your implementation works correctly.
|
||||
|
||||
**This testing section is locked** - it provides consistent feedback across all modules and cannot be modified.
|
||||
"""
|
||||
|
||||
# %% nbgrader={"grade": false, "grade_id": "standardized-testing", "locked": true, "schema_version": 3, "solution": false, "task": false}
|
||||
# =============================================================================
|
||||
# STANDARDIZED MODULE TESTING - DO NOT MODIFY
|
||||
# This cell is locked to ensure consistent testing across all TinyTorch modules
|
||||
# =============================================================================
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Unit tests
|
||||
test_compression_metrics()
|
||||
test_magnitude_pruning()
|
||||
test_quantization()
|
||||
test_distillation()
|
||||
test_structured_pruning()
|
||||
test_comprehensive_comparison()
|
||||
# Integration tests
|
||||
test_compression_integration()
|
||||
test_comprehensive_compression_integration()
|
||||
|
||||
from tito.tools.testing import run_module_tests_auto
|
||||
# Automatically discover and run all tests in this module
|
||||
success = run_module_tests_auto("Compression")
|
||||
|
||||
Reference in New Issue
Block a user