From ba2a264fb54c0f5cb7663bf0cf6e698a53132a59 Mon Sep 17 00:00:00 2001 From: Vijay Janapa Reddi Date: Sun, 20 Jul 2025 09:42:47 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=2012=5Fcompression:=20Move=20in?= =?UTF-8?q?tegration=20tests=20BEFORE=20testing,=20clean=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../source/12_compression/compression_dev.py | 65 +++++++------------ 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/modules/source/12_compression/compression_dev.py b/modules/source/12_compression/compression_dev.py index 8c643364..91e84fa4 100644 --- a/modules/source/12_compression/compression_dev.py +++ b/modules/source/12_compression/compression_dev.py @@ -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")