Skip to content

The best ChatGPT that $100 can buy.

Python

Fix: Handle missing d<number> model tags in find_largest_model

Mirza-Samad-Ahmed-Baigafaa5b4c905f
diff --git a/nanochat/checkpoint_manager.py b/nanochat/checkpoint_manager.py
index 961ebd5..f400d47 100644
--- a/nanochat/checkpoint_manager.py
+++ b/nanochat/checkpoint_manager.py
@@ -104,8 +104,8 @@ def find_largest_model(checkpoint_dir):
candidates.sort(key=lambda x: x[0], reverse=True)
return candidates[0][1]
# 2) if that failed, take the most recently updated model:
- candidates.sort(key=lambda x: os.path.getmtime(os.path.join(checkpoint_dir, x[1])), reverse=True)
- return candidates[0][1]
+ model_tags.sort(key=lambda x: os.path.getmtime(os.path.join(checkpoint_dir, x)), reverse=True)
+ return model_tags[0]
def find_last_step(checkpoint_dir):