Repository navigation
Description
When an S3 audio dataset uses a manifest-relative path such as clips/a.wav, adding another clips/a.wav at the selected prefix root silently redirects that row to the other audio file. Its transcript stays unchanged, producing an incorrect training pair.
Environment
Where are you using Unsloth?
- Unsloth desktop application
- Unsloth web UI (
unsloth studio) backend data preparation - Unsloth CLI
- Python package or notebook
- Colab or Kaggle
What happened?
Steps to reproduce:
- Select S3 prefix
datasets/with:datasets/train/metadata.jsonl # {"audio":"clips/a.wav","text":"transcript for train clip"} datasets/train/clips/a.wav datasets/clips/a.wav # a different recording - Run the manifest rewrite during S3 dataset preparation.
- Compare
clips/a.wavwith./clips/a.wavin the same manifest.
Expected behavior: Preserve the manifest-relative target, or explicitly reject the ambiguity. Adding an unrelated recording should not silently change an existing audio/transcript pair. Manifest-relative references are supported by the existing test and #10050.
Actual behavior:
| Reference | Prefix-root collision | Rewritten target |
|---|---|---|
clips/a.wav |
absent | train/clips/a.wav |
clips/a.wav |
present | clips/a.wav (different recording) |
./clips/a.wav |
present | train/clips/a.wav |
| explicit S3 URI to train clip | present | train/clips/a.wav |
No error is raised; the transcription is retained.
Model and operation involved: S3 audio/transcription preparation for training, e.g. Whisper. Model-independent; no training run or AWS access was needed to reproduce the rewrite.
Diagnostics and logs
Python package or notebook, if applicable
Minimal reproduction from the repository root in a Studio environment:
import json
import sys
import tempfile
from pathlib import Path
sys.path.insert(0, "studio/backend")
from core.training.s3_dataset import _rewrite_audio_references
with tempfile.TemporaryDirectory() as folder:
root = Path(folder)
manifest = root / "train/metadata.jsonl"
manifest.parent.mkdir()
for value in ("clips/a.wav", "./clips/a.wav"):
manifest.write_text(json.dumps({"audio": value, "text": "train clip"}))
_rewrite_audio_references(
{"datasets/train/metadata.jsonl": str(manifest)},
{
"datasets/train/clips/a.wav": str(root / "train/clips/a.wav"),
"datasets/clips/a.wav": str(root / "clips/a.wav"),
},
"test-bucket", "datasets/",
)
target = json.loads(manifest.read_text())["audio"]
print(value, "->", Path(target).relative_to(root))Output: clips/a.wav -> clips/a.wav, but ./clips/a.wav -> train/clips/a.wav.
Executed validation: Loaded the unchanged rewrite functions and audio-extension constant from source via AST to avoid unrelated backend imports, using temporary local manifests and distinct local file contents. JSONL, JSON arrays, and CSV each reproduced the wrong target; all nine no-collision/explicit-relative/explicit-URI controls passed, on both SHAs above. The normal S3 test module could not collect in the minimal environment because backend imports require httpx; no claim of a full S3 or model-training test.
Desktop diagnostics, web UI logs, model logs, and nvidia-smi: not applicable to this isolated backend reproduction.
Additional context
Resolver lines 232–239 return a prefix-relative match before checking the manifest-relative candidate. Both matching different files is not detected.
Suggested direction: detect conflicting candidates and ask for an explicit ./ reference or full S3 URI. Keep unambiguous references working. Simply reversing precedence would instead change existing prefix-relative datasets. Scope should be this resolver and focused JSON/JSONL/CSV regression tests.
Activity
fix(studio): reject ambiguous S3 audio references (unslothai#16529)