Skip to content

Commit 885e09f

Browse files
committed
fix: retry colab upload calls in the chunk loop and concat step
Real failure on the 5645-char/9-chunk long-form test (2026-08-17): after ~55min and 8 successful chunks, chunk 9's upload of chunk_index.txt failed: "File or directory not found: /content/chunk_index.txt". Traced into google-colab-cli's contents.py: that exact message is raised on an HTTP 404 from the Colab backend's Contents API, not a missing local file -- the session/kernel had gone away, likely from sustained load near the end of a long run. Because the Colab VM is stateful but ephemeral, losing the session this late threw away the entire run's completed work (8 chunks of real GPU time) with nothing to resume from. Added upload_with_retry() (3 attempts, 20s backoff) around both uploads in the per-chunk loop, and the same retry around chunk_count.txt's upload before the final concat step -- that one runs after all chunks finish, so a transient failure there would be equally expensive. Doesn't address a session that's genuinely dead (retries will just fail three times and report clearly), but does recover from the more likely transient-hiccup case. Re-running the 9-chunk long-form test next to confirm.
1 parent 4e2dac1 commit 885e09f

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

.github/workflows/synthesize.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,34 @@ jobs:
207207
SESSION="${{ steps.colab_new.outputs.session }}"
208208
N=$(cat chunk_count.txt)
209209
echo "synthesizing $N chunk(s)"
210+
211+
# 2026-08-17 real failure: a 9-chunk run (~55min in) died on the
212+
# LAST chunk's upload with "File or directory not found:
213+
# /content/...". Traced into colab_cli/contents.py: that message
214+
# is what it raises on an HTTP 404 from the Colab backend's
215+
# Contents API -- i.e. the session/kernel had gone away, not a
216+
# missing local file. A single transient hiccup this late costs
217+
# the entire run's already-completed work (the VM is stateful
218+
# but ephemeral -- nothing survives to resume from). Retry
219+
# uploads a few times before giving up.
220+
upload_with_retry () {
221+
local local_path="$1" remote_path="$2" attempt
222+
for attempt in 1 2 3; do
223+
if colab --auth=adc upload -s "$SESSION" "$local_path" "$remote_path"; then
224+
return 0
225+
fi
226+
echo "::warning::upload of $local_path attempt $attempt failed; retrying in 20s..."
227+
sleep 20
228+
done
229+
echo "::error::upload of $local_path failed after 3 attempts -- session likely died"
230+
return 1
231+
}
232+
210233
for i in $(seq 0 $((N - 1))); do
211234
echo "=== chunk $i/$((N - 1)) ==="
212235
echo -n "$i" > chunk_index.txt
213-
colab --auth=adc upload -s "$SESSION" chunk_index.txt /content/chunk_index.txt
214-
colab --auth=adc upload -s "$SESSION" "batch_chunk_$i.jsonl" "/content/batch_chunk_$i.jsonl"
236+
upload_with_retry chunk_index.txt /content/chunk_index.txt
237+
upload_with_retry "batch_chunk_$i.jsonl" "/content/batch_chunk_$i.jsonl"
215238
# Each call only pays model-load + that chunk's synth time (env
216239
# and model weights are already on disk from the setup step).
217240
# 1800s covers CHUNK_MAX_CHARS=700 with margin; see
@@ -230,7 +253,15 @@ jobs:
230253
run: |
231254
set -o pipefail
232255
SESSION="${{ steps.colab_new.outputs.session }}"
233-
colab --auth=adc upload -s "$SESSION" chunk_count.txt /content/chunk_count.txt
256+
# Same rationale as the retry wrapper in the chunk loop above --
257+
# this runs after all chunks are done, so a transient upload
258+
# failure here would waste that entire completed run too.
259+
for attempt in 1 2 3; do
260+
colab --auth=adc upload -s "$SESSION" chunk_count.txt /content/chunk_count.txt && break
261+
echo "::warning::chunk_count.txt upload attempt $attempt failed; retrying in 20s..."
262+
sleep 20
263+
[ "$attempt" = 3 ] && { echo "::error::chunk_count.txt upload failed after 3 attempts"; exit 1; }
264+
done
234265
colab --auth=adc exec -s "$SESSION" -f colab_job/concat_chunks.py --timeout 120 \
235266
2>&1 | tee /tmp/exec_concat.log
236267
if grep -q '^FATAL:' /tmp/exec_concat.log; then

0 commit comments

Comments
 (0)