Upload train_sft.py
Browse files209 unmodified lines210211212213214215216207 unmodified lines424425426427428429430473 unmodified lines904905906907908909910911912913914915916917918919920921209 unmodified linesEMPTY_CACHE_EVERY = 50# SFT-specific hyperparameters (same for all GPUs)MAX_LR = 1e-05 # reverted from 3e-05 back to 1e-05 — this is# the PROVEN value from the working 250M run;# 3e-05 combined with our smaller batch size# caused training instability and garbage output207 unmodified lineslog(f" ⚠️ File is still saved locally at: {path}")log(f" ⚠️ Please upload manually before shutting down GPU!")else:# Background upload (for mid-training saves — doesn't block GPU)def _bg_upload():try:with_retry(api.upload_file, path_or_fileobj=path,473 unmodified linesfinal_val_for_save,"sft_ckpt_latest.pt", blocking=True, best_val_loss=best_val_loss)# Upload best checkpoint at the very end (only once, saves GPU time)if IS_MAIN and os.path.exists(f"{WORK}/{SFT_CHECKPOINT_DIR}/sft_ckpt_best.pt"):log(f" ☁️ Uploading best checkpoint to HF (blocking, please wait)...")try:with_retry(api.upload_file, path_or_fileobj=f"{WORK}/{SFT_CHECKPOINT_DIR}/sft_ckpt_best.pt",path_in_repo=f"{SFT_CHECKPOINT_DIR}/sft_ckpt_best.pt",repo_id=MAIN_REPO, repo_type="model", token=HF_TOKEN)log(f" ✅ Best checkpoint uploaded to HF!")except Exception as e:log(f" ❌ Best checkpoint upload failed: {e}")log(f" ⚠️ File saved locally at: {WORK}/sft_checkpoints/sft_ckpt_best.pt")log(f" ⚠️ Please upload manually before shutting down GPU!")# Wait for any remaining background uploads from mid-training savesif IS_MAIN:209 unmodified lines210211212213214215216207 unmodified lines424425426427428429430431432433434473 unmodified lines908909910911912913914915209 unmodified linesEMPTY_CACHE_EVERY = 50# SFT-specific hyperparameters (same for all GPUs)MAX_LR = 5e-05 # Increased from 1e-05 to 5e-05 to quickly learn new chat tokens# the PROVEN value from the working 250M run;# 3e-05 combined with our smaller batch size# caused training instability and garbage output207 unmodified lineslog(f" ⚠️ File is still saved locally at: {path}")log(f" ⚠️ Please upload manually before shutting down GPU!")else:# Background upload (for mid-training saves - doesn't block GPU)if filename == "sft_ckpt_best.pt":log(f" 📌 Skipping background upload for {filename} as requested.")returndef _bg_upload():try:with_retry(api.upload_file, path_or_fileobj=path,473 unmodified linesfinal_val_for_save,"sft_ckpt_latest.pt", blocking=True, best_val_loss=best_val_loss)if IS_MAIN and os.path.exists(f"{WORK}/{SFT_CHECKPOINT_DIR}/sft_ckpt_best.pt"):log(f" 📌 Skipping best checkpoint upload to HF as requested. File saved locally at: {WORK}/{SFT_CHECKPOINT_DIR}/sft_ckpt_best.pt")# Wait for any remaining background uploads from mid-training savesif IS_MAIN:
code/train_sft.py+7-13