[PR #1337] [MERGED] test(tinytorch): add coverage tests for Module 08 training infrastructure #8128

Closed
opened 2026-04-27 17:25:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1337
Author: @Shashank-Tripathi-07
Created: 4/16/2026
Status: Merged
Merged: 4/16/2026
Merged by: @profvjreddi

Base: devHead: test/training-module-coverage


📝 Commits (2)

  • 6b42b75 test(tinytorch): add coverage tests for Module 08 training infrastructure
  • 13972d6 fix(tests/08_training): correct scheduler lr assertion to use epoch 0 not epoch 1

📊 Changes

1 file changed (+480 additions, -0 deletions)

View changed files

tinytorch/tests/08_training/test_training_coverage.py (+480 -0)

📄 Description

Summary

Six areas of Module 08 were fully implemented but had zero test coverage. This PR fills those gaps with a dedicated test_training_coverage.py.

Coverage

Area What's tested
CosineSchedule Start/mid/end values, monotonic decrease, past-end edge case, single-epoch schedule
clip_grad_norm Clipping, no-clip, multi-param global norm, direction preserved, zero-grad safety, returns original norm
save/load_checkpoint File created, all keys present, epoch/step/history/weights restored, training resumes correctly, creates parent dirs
Trainer.evaluate Finite loss, float return types, eval mode set, weights unchanged, history recorded per call, classification accuracy (correct and wrong)
Scheduler integration LR recorded in history, optimizer.lr updated to match schedule, decreases over epochs
Gradient clipping integration Training completes without crash, weights still update, tight clip limits update magnitude
Train/eval mode switching model.training correct after train_epoch, evaluate, and train/eval/train cycle

Files

File Change
tinytorch/tests/08_training/test_training_coverage.py New: 478 lines, 36 tests

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1337 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 4/16/2026 **Status:** ✅ Merged **Merged:** 4/16/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `test/training-module-coverage` --- ### 📝 Commits (2) - [`6b42b75`](https://github.com/harvard-edge/cs249r_book/commit/6b42b75b55dfbec66f575bd20f27a517f9b41f9f) test(tinytorch): add coverage tests for Module 08 training infrastructure - [`13972d6`](https://github.com/harvard-edge/cs249r_book/commit/13972d6807dda94a0dc44388d5afa24cc1a11efc) fix(tests/08_training): correct scheduler lr assertion to use epoch 0 not epoch 1 ### 📊 Changes **1 file changed** (+480 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `tinytorch/tests/08_training/test_training_coverage.py` (+480 -0) </details> ### 📄 Description ## Summary Six areas of Module 08 were fully implemented but had zero test coverage. This PR fills those gaps with a dedicated `test_training_coverage.py`. ## Coverage | Area | What's tested | |------|--------------| | `CosineSchedule` | Start/mid/end values, monotonic decrease, past-end edge case, single-epoch schedule | | `clip_grad_norm` | Clipping, no-clip, multi-param global norm, direction preserved, zero-grad safety, returns original norm | | `save/load_checkpoint` | File created, all keys present, epoch/step/history/weights restored, training resumes correctly, creates parent dirs | | `Trainer.evaluate` | Finite loss, float return types, eval mode set, weights unchanged, history recorded per call, classification accuracy (correct and wrong) | | Scheduler integration | LR recorded in history, `optimizer.lr` updated to match schedule, decreases over epochs | | Gradient clipping integration | Training completes without crash, weights still update, tight clip limits update magnitude | | Train/eval mode switching | `model.training` correct after `train_epoch`, `evaluate`, and train/eval/train cycle | ## Files | File | Change | |------|--------| | `tinytorch/tests/08_training/test_training_coverage.py` | New: 478 lines, 36 tests | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-27 17:25:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#8128