Fix delete_original crash for regular checkpoint files - #362
Nikhi00718 wants to merge 1 commit into
Conversation
|
Verified this one works — I ran it against the real call shape ( Just so it's visible to whoever triages: there are four open PRs on this same helper.
Your diff is logically identical to #303, which landed first and also ships a test. Nothing wrong with your version — just flagging the overlap so the maintainer doesn't review the same change three times, and so you don't spend more effort on something already covered. #337 is the only one that differs meaningfully: it normalises with (I couldn't exercise the symlink path — no symlink permission on this box without elevation — so that part is unverified by me.) |
Summary
delete_original=Truecurrently crashes while deleting a regular checkpoint file.split_and_save_layers()passes aPath, butremove_real_and_linked_file()comparesos.path.realpath()'s string result with thatPath, assumes the file is linked, and removes the same file twice.This patch checks
os.path.islink()directly, so regular files are removed once and symlink targets are removed only for actual symlinks.Fixes #297.
Verification
Path, relativePath, absolute string, and symlink inputs.47 passed, 1 skippedin the focused splitter/LoRA/test suite; the skipped test requires Windows symlink permission.python -m compileall -q air_llm eval examples rlhf scripts training anima_100ksplit_and_save_layers(..., delete_original=True)run.Please review when you have a chance, @lyogavin.