Skip to content

Studio: resolve S3 Parquet audio paths before loading - #18008

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
DimitriChrysafis:fix/studio-s3-parquet-audio-paths
Nov 18, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
DimitriChrysafis:fix/studio-s3-parquet-audio-paths

Conversation

@DimitriChrysafis

@DimitriChrysafis DimitriChrysafis commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

S3 audio downloads leave paths in Parquet manifests unchanged. A row pointing to audio/a.wav still resolves against the process working directory after the recording is downloaded into a fresh unsloth_s3_dataset_* directory. Full s3:// references also bypass the downloaded copy. JSON, JSONL and CSV manifests already use the local paths. The Parquet limitation was noted in the review of #16830.

Apply the existing reference resolver to Parquet rows in batches of 1,024, preserving the Arrow schema and Hugging Face feature metadata. Paths use the allocator's actual filenames, including collision suffixes. A completed rewrite replaces the manifest atomically; ambiguity or write errors leave the original intact and remove the staged file. A manifest without matching references stays byte-identical.

The S3 fake now writes real Parquet rather than text under a .parquet filename, so the existing download and collision tests continue to exercise valid input.

Validation on macOS, Python 3.12.4, datasets 4.3.0 and PyArrow 21.0.0:

  • The initial regression run has 12 failures on unchanged main.
  • All 138 tests pass across the audio download, general S3, optional-SDK and runtime suites.
  • Coverage includes string paths, undecoded HF Audio structs, lists, nulls, embedded bytes, prefix/manifest-relative paths, full S3 URIs, colliding keys, later-batch ambiguity, and an injected full-disk error. A real datasets.load_dataset round trip preserves Audio features and resolves a WAV whose sample bytes and sample rate are checked.
  • Repository-pinned Ruff lint and formatting, duplicate-definition and import-hoist checks, and git diff --check pass.
python -m pytest studio/backend/tests/test_s3_audio_dataset.py \
  studio/backend/tests/test_s3_dataset.py studio/backend/tests/test_s3_optional.py \
  studio/backend/tests/test_s3_runtime.py -q --tb=short --timeout=60

S3 transport is faked. No AWS service call, model training, or GPU run.

Follow-up fixes on this branch:

  • Apple Silicon (MLX) training deleted the S3 download right after loading the manifest, before _mlx_audio_rows decoded the clips, so S3 audio training there failed for JSON, JSONL, CSV and Parquet manifests alike. The worker now keeps an S3 audio download until the run ends. test_mlx_s3_audio_download_outlives_the_model_load fails without this change.
  • The no-manifest error now lists Parquet among the supported manifest formats.
  • A test read the rewritten manifest without an encoding, which failed on Windows (cp1252). It now reads UTF-8.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-18T11:18:56.355378Z
We couldn’t complete this review. Comment @codex review to try again.
2341b0e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 280fad161c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +403 to +404
for batch in source.iter_batches(batch_size = 1024):
writer.write_table(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor cancellation between Parquet rewrite batches

For a large S3 Parquet shard, a Stop/Cancel request arriving during this loop is ignored until every remaining batch has been read and recompressed: prepare_s3_dataset_download() passes cancel_callback to the download helpers, but not to _rewrite_audio_references() or this rewriter. This can keep a cancelled run busy for minutes and, if training.py::_stop_watchdog_loop force-terminates it, bypass removal of the owned download directory. Thread the cancellation callback through and check it between batches so S3DownloadCancelled reaches the existing cleanup path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: a cancel during the rewrite still takes effect, since the audio download that follows checks it before every file. The rewrite runs about 5 us per row locally (200k rows in 0.94 s), so the delay is seconds at most and far below the audio download it precedes.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 280fad161c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 18, 2026
danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 18, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 2341b0e1ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen marked this pull request as ready for review November 18, 2026 11:18
@danielhanchen
danielhanchen merged commit bd6521b into unslothai:main Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants