Skip to content

Studio: load S3 audio datasets — download the audio beside its manifest and point the manifest at it - #10050

Merged
danielhanchen merged 12 commits into
unslothai:mainfrom
lonexreb:feat/s3-audio-datasets
Oct 5, 2026
Merged

danielhanchen merged 12 commits into
unslothai:mainfrom
lonexreb:feat/s3-audio-datasets

Conversation

@lonexreb

@lonexreb lonexreb commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4539.

What

#6222 gave training an S3 dataset source, deliberately tabular-only: the key listing filters audio files out, every download flattens to its basename, and a manifest+audio prefix trips the mixed-format validation. So the layout #4539 asks for — Whisper finetuning with audio files on S3 plus a transcription manifest — could never load: at best the manifest downloaded alone, and training died when datasets.Audio tried to open paths that were never materialized (Audio opens path strings verbatim; nothing in the local path rebases them).

How

Backend in core/training/s3_dataset.py — the trainer, routes, and S3Config are untouched:

  • Audio keys under the prefix download too (the same _AUDIO_EXTENSIONS the format detector uses), preserving their prefix-relative key structure so the manifest's relative references stay true.
  • The manifest's audio values are rewritten to the materialized absolute paths, matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths. Anything unmatched is left exactly as written — it may be an absolute path or URL that is somebody else's contract to satisfy. JSON/JSONL/CSV manifests are rewritable; parquet would need pyarrow, so its references must already be absolute (stated in the module docstring).
  • The single-format rule now judges only the manifest files. Audio beside one manifest family is the expected shape; two manifest families still error; audio with no manifest errors naming exactly what's missing.
  • Tabular-only prefixes keep feat(studio): implement S3 dataset loading (completes #5951) #6222's flat, collision-renamed layout byte for byte — pinned by a test.
  • Path-traversal guard: the structured layout joins S3 keys into filesystem paths and bucket contents are external input, so a key carrying .. segments refuses the download instead of writing above the dataset directory.

Frontend (0dabecd, after review): three gates turned an audio model away from S3 with the same "vision or audio" test — dataset-section.tsx reset the source to Browse, dataset-source-toggle.tsx hid the S3 option, and validateS3Source refused the start — so the backend path was unreachable from the UI. They now gate on vision alone; the s3MultimodalUnsupported string drops "or audio" in every locale. UI flow: audio model → Dataset → Amazon S3 → bucket/prefix → Start.

Credentials handling is exactly #6222's (explicit keys or the default chain / IAM role, never logged or persisted).

Verification

  • New tests/test_s3_audio_dataset.py (9 tests, house fake-client pattern — no boto3, network, or credentials needed): structure-preserving download, both validation changes, all four reference forms rewritten (plus unmatched-left-alone), CSV and JSONL manifests, the flat-layout pin, and the traversal guard. RED-verified: 5 of the original 8 fail on unmodified main, the traversal test fails without its guard.
  • All 15 existing test_s3_dataset.py tests pass unchanged — feat(studio): implement S3 dataset loading (completes #5951) #6222's contract is intact.
  • Frontend: tests/training-validation.test.ts gains the audio-ok / vision-still-refused pair (audio case fails on the previous head); 6853/6853 frontend tests, typecheck clean.
  • All S3-touching suites (test_training_resume, test_training_cached_start, S3 old+new): 213 passed. ruff clean; scripts/run_ruff_format.py makes no further changes.

cc @Huuffy (volunteered on the issue in March — review very welcome), @Androidmedaa (reporter: with this, pointing the S3 dataset source at a prefix holding your audio plus a metadata.jsonl/.csv of transcriptions should feed the Whisper finetune directly).

UI before / after

Audio model (unsloth/whisper-large-v3-turbo) selected on the Train page. Before: merge base 729cc3f. After: a0f08b0. Each side was a separate install.

With an audio model, the Dataset section now offers the Browse / Amazon S3 toggle. Before, it was hidden:

Dataset section with an audio model, before and after

Clicking Amazon S3 opens the S3 configuration form and the source stays on S3. Before, there was nothing to click:

After clicking Amazon S3, before and after

@lonexreb

lonexreb commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Fair question: on 09e2127 a user could not reach it from the UI at all. Three frontend gates turned an audio model away from S3 with the same "vision or audio" test: dataset-section.tsx reset the source back to Browse with the multimodal toast, dataset-source-toggle.tsx hid the S3 option, and validateS3Source refused the start. The backend change alone only helped an API caller.

Fixed in 0dabecd: all three now gate on vision alone (the modality whose references the downloader does not yet rewrite), so an audio model shows the S3 toggle, keeps the S3 form, and starts; a vision model behaves exactly as before. The s3MultimodalUnsupported string drops "or audio" in every locale. The flow from the UI is then: pick an audio model → Dataset → Amazon S3 → bucket/prefix → Start; the worker downloads the manifest plus its audio beside it and rewrites the references, as the backend tests pin.

Regression in tests/training-validation.test.ts: an audio model with a bucket validates ok (fails on the previous head), a vision model still gets s3MultimodalUnsupported. Frontend: 6853/6853 tests, typecheck clean, biome clean on the touched files. Also rebased onto main at 2d346cc to clear the conflict in _list_dataset_keys (main's AppleDouble filter now applies to both the manifest and audio lists).

@danielhanchen

Copy link
Copy Markdown
Member

Checked that main's _list_dataset_keys still drops audio keys and flattens downloads, and the follow-up on 0dabecd answers my question by gating the three frontend checks on vision alone, so an audio model can actually reach S3 now. Will get this reviewed.

@lonexreb
lonexreb force-pushed the feat/s3-audio-datasets branch 5 times, most recently from c066e37 to d740d66 Compare September 16, 2026 14:57
@Huuffy

Huuffy commented Sep 25, 2026

Copy link
Copy Markdown

hi i was out of touch lmk if i can help in anything

@lonexreb

Copy link
Copy Markdown
Contributor Author

Welcome back, and thanks. The most useful thing now would be a real run: point an audio model at an S3 prefix holding a JSONL/CSV manifest plus its audio files (the layout from #4539) on this branch, and say whether the download lands beside the manifest and the finetune starts. A review of core/training/s3_dataset.py is welcome too; the backend tests fake the S3 client, so a run against a real bucket is the one thing they cannot cover.

lonexreb and others added 3 commits September 26, 2026 18:10
…st and point the manifest at it

key listing filtered audio files out, every download flattened to its
basename, and a manifest+audio prefix was called a mixed-format error.
So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on
S3 plus a transcription manifest -- could never load: at best the
manifest downloaded alone and training died when datasets.Audio tried
to open paths that were never materialized.

Audio keys under the prefix now download too, preserving their
prefix-relative structure so the manifest's relative references stay
true, and the manifest's audio values are rewritten to the materialized
absolute paths -- matching prefix-relative keys, s3://bucket/key URIs,
the HF undecoded {"path": ...} shape, and manifest-relative paths;
anything unmatched is left exactly as written. The single-format rule
now judges only the manifest files (audio beside one manifest family is
the expected shape; audio with no manifest is an error naming what is
missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed
layout byte for byte. Since the structured layout joins S3 keys into
filesystem paths and bucket contents are external input, a key carrying
'..' segments refuses the download instead of writing above the
dataset directory.

Credentials handling is untouched from unslothai#6222 (explicit keys or the
default chain/IAM role, never logged or persisted). Parquet manifests
cannot be rewritten without pyarrow; their audio references must
already be absolute, which the module docstring now states.

Closes unslothai#4539.
The backend half loads an S3 audio dataset, but the frontend still
turned the source back to Browse for any audio model: dataset-section
reset it with the multimodal toast, dataset-source-toggle hid the S3
option, and validateS3Source refused the start. All three gated on
"vision or audio"; they now gate on vision alone, which is the modality
whose references the downloader does not yet rewrite. The message that
names the gate drops "or audio" in every locale.

Regression in training-validation.test.ts: an audio model with a bucket
validates ok, a vision model still gets s3MultimodalUnsupported. The
audio case fails on the previous head.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
@Huuffy

Huuffy commented Oct 1, 2026

Copy link
Copy Markdown

s3_dataset.py is upto the standards but I am looking for a real test I have access and credits on AWS s3 we could make a test bucket

The fake-client suite pins the contract; this runs the same manifest and
audio shape through boto3 and a network. It is skipped unless
UNSLOTH_S3_LIVE_BUCKET names a bucket the ambient credentials can write
to, uploads under a unique prefix, and deletes it afterwards.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012DRiTpjxAymRtv9p8Xr2kd
@lonexreb

lonexreb commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, and yes, a real bucket run is the right ask. Two things:

1. I ran it live over the network. Real boto3 (1.43), the branch's download_s3_dataset untouched, against a standalone S3 server (moto in server mode on AWS_ENDPOINT_URL_S3): uploaded a JSONL manifest plus audio/a.wav and audio/sub/b.wav under a prefix, ran the loader, and checked the result. The audio landed beside the manifest with the sub-folder kept, the four reference forms (prefix-relative, s3:// URI, HF {"path": ...}, and an unrelated https URL left alone) came back rewritten to the materialised absolute paths, and the wav frames survived byte for byte.

2. I added that run to the PR as an opt-in test (c2a3b55): studio/backend/tests/test_s3_audio_dataset_live.py. It skips unless a bucket is named, uploads under a unique unsloth-live-<id>/ prefix, and deletes it afterwards, so CI stays offline and nothing is left behind. Against your bucket it is one line:

UNSLOTH_S3_LIVE_BUCKET=<your-test-bucket> AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_DEFAULT_REGION=<region> \
  pytest studio/backend/tests/test_s3_audio_dataset_live.py -q

(Or leave the key vars unset to go through the default credential chain / IAM role, which is the branch's other code path.) If you can run that on real AWS and paste the one-line result here, that closes the gap I cannot close from this side. It only needs put/list/get/delete on that bucket.

@Huuffy

Huuffy commented Oct 2, 2026

Copy link
Copy Markdown

Ye can do. Will get back to you on that

@lonexreb

lonexreb commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Ran this head (9cf12a5) against a real S3 API rather than mocks: a local S3-compatible server (moto 5.2.3 behind AWS_ENDPOINT_URL_S3, real boto3 1.43), the Whisper layout from #4539 in a bucket (metadata.jsonl beside audio/a.wav and audio/sub/b.wav, rows referencing the audio four ways: prefix-relative, s3:// URI, the HF {"path": …} shape, and an external https:// URL), then download_s3_dataset from main and from this branch on the same objects.

returned files materialized under dest manifest rows afterwards
main metadata.jsonl metadata.jsonl only unchanged: audio/a.wav, s3://…/b.wav, {"path": "audio/a.wav"}, none of which exists locally
this PR metadata.jsonl metadata.jsonl, audio/a.wav, audio/sub/b.wav (structure kept) the three S3-backed rows rewritten to the absolute materialized paths, all of which exist; the https:// row left exactly as written

So main hands the trainer a manifest whose every audio path dangles, which is the datasets.Audio failure the issue describes, and this branch hands it one that resolves. The PR's own test_s3_audio_dataset_live.py passes against the same server (UNSLOTH_S3_LIVE_BUCKET=unsloth-live AWS_ENDPOINT_URL_S3=http://127.0.0.1:9000), WAV frame counts intact after the round trip. For anyone else wanting a no-AWS run of that test, that pair of env vars plus any AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY is all it needs.

@danielhanchen danielhanchen self-assigned this Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 4, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #10050, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#397.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror b8d0bbb9fe (this PR's a0f08b02c)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b8d0bbb9fe

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror b8d0bbb9fe (this PR's a0f08b02c).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

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.

[Feature] Unsloth/ Whisper/Large-v3 - S3 Bucket connection

3 participants