fix: add retry with exponential backoff to download_file_with_lock#555
Open
icenfly wants to merge 1 commit intokarpathy:masterfrom
Open
fix: add retry with exponential backoff to download_file_with_lock#555icenfly wants to merge 1 commit intokarpathy:masterfrom
icenfly wants to merge 1 commit intokarpathy:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #554
Impact
Prevents transient network failures (DNS resolution, connection timeout, etc.) from crashing multi-GPU training runs. Without this fix, a single network hiccup during eval_bundle.zip download at step 2000 causes all 8 ranks to hang and abort via NCCL watchdog, losing hours of training progress.
Change
Added retry logic with exponential backoff and explicit timeout to download_file_with_lock in nanochat/common.py, matching the existing pattern used by download_single_file in nanochat/dataset.py:
• max_attempts = 5 with exponential backoff (2^attempt seconds)
• timeout=30 on urlopen (same as dataset.py's requests.get..., timeout=30))
• Partial file cleanup on failure
• Consistent error message format: Attempt {attempt}/{max_attempts} failed for {filename}: {e}
On a healthy network, the download succeeds on the first attempt and behavior is identical to the original. The existing FileLock mechanism for multi-rank co ordination is unchanged.