[PR #1939] [MERGED] fix(mlperf-edu): NameError masks real model-load failure in auto_trainer #36549

Closed
opened 2026-07-16 00:27:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: devHead: fix/auto-trainer-load-failure-nameerror


📝 Commits (1)

  • eb0145d fix(mlperf-edu): NameError masks real model-load failure in auto_trainer

📊 Changes

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

View changed files

📝 mlperf-edu/scripts/orchestration/auto_trainer.py (+5 -0)

📄 Description

Summary

  • If _load_model() raised on the very first NAS attempt (nas_attempt=0), the except block printed the error and breakd out of the outer while loop before model was ever bound.
  • Execution then fell through to torch.save(model.state_dict(), save_path), raising NameError: name 'model' is not defined and hiding the real load failure behind an unrelated crash.

Fix

Initialize model = None before the loop and check it after, returning early with a clear log message instead of crashing if the model never loaded successfully.

Test plan

  • Simulated the control flow in isolation (pure Python, no torch needed): confirmed the old logic would crash on model.state_dict() after a load failure; with the fix, it logs Aborting: model never loaded successfully, nothing to save. and returns cleanly.
  • python -m py_compile passes on the edited file.

🔄 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/1939 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 7/7/2026 **Status:** ✅ Merged **Merged:** 7/10/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/auto-trainer-load-failure-nameerror` --- ### 📝 Commits (1) - [`eb0145d`](https://github.com/harvard-edge/cs249r_book/commit/eb0145d4e1679242b28bfe43cadd1372696cfb0e) fix(mlperf-edu): NameError masks real model-load failure in auto_trainer ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `mlperf-edu/scripts/orchestration/auto_trainer.py` (+5 -0) </details> ### 📄 Description ## Summary - If `_load_model()` raised on the very first NAS attempt (`nas_attempt=0`), the `except` block printed the error and `break`d out of the outer `while` loop before `model` was ever bound. - Execution then fell through to `torch.save(model.state_dict(), save_path)`, raising `NameError: name 'model' is not defined` and hiding the real load failure behind an unrelated crash. ## Fix Initialize `model = None` before the loop and check it after, returning early with a clear log message instead of crashing if the model never loaded successfully. ## Test plan - [x] Simulated the control flow in isolation (pure Python, no torch needed): confirmed the old logic would crash on `model.state_dict()` after a load failure; with the fix, it logs `Aborting: model never loaded successfully, nothing to save.` and returns cleanly. - [x] `python -m py_compile` passes on the edited file. --- <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-07-16 00:27:46 -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#36549