Skip to content

[Bug][Studio] SFT dataset load fails when HF repo contains sidecar JSON (filter_report.json / dataset_manifest.json) #7585

Closed as not planned

Description

@Momix-77

Summary

Unsloth Studio SFT fails while generating/loading a Hugging Face dataset when the dataset repo contains non-row sidecar JSON files next to the actual training files (e.g. train.jsonl).

HF's json builder treats those sidecars as data files, then raises a schema mismatch (DatasetGenerationCastError / column cast error).

This is a Studio/dataset-loading bug, not a problem with valid SFT row schemas.

Environment

  • Product: Unsloth Studio (local UI / unsloth studio)
  • OS: Linux
  • Repro path: Studio UI → select HF dataset → start SFT
  • Also affects format-check / preview paths that load hub data via datasets.load_dataset

Reproduction (minimal)

Create a tiny HF dataset repo (or local snapshot folder) with:

train.jsonl
val.jsonl
filter_report.json
dataset_manifest.json
README.md

train.jsonl (SFT rows):

{"messages":[{"role":"user","content":"hi"},{"role":"assistant","content":"yo"}],"instruction":"i","input":"","output":"o","metadata":{"series":"s"}}

filter_report.json (sidecar, different schema):

{"reasons":[],"total_in":1,"series":"s","kept":1}

dataset_manifest.json (sidecar, different schema):

{"repo":"x","source_root":"y","original_data_only":true,"run_id":"1","chroma_collection":"c"}

Then in Studio:

  1. Point training at this HF dataset (or local directory containing these files)
  2. Start SFT (non-streaming load)

Expected

Studio loads only row-oriented training files (train.jsonl / val.jsonl / test.jsonl, parquet/csv, etc.) and ignores report/manifest sidecars.

Actual

Training fails with an error similar to:

An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 4 new columns
({'reasons', 'total_in', 'series', 'kept'}) and 5 missing columns
({'repo', 'source_root', 'original_data_only', 'run_id', 'chroma_collection'}).

This happened while the json dataset builder was generating data using
.../filter_report.json

Please either edit the data files to have matching columns, or separate them into different configurations
(see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Related failure mode (same root class)

Even without sidecars, hub dataset_info.features / card Features that omit optional nested columns (e.g. metadata) can also break preview/training:

Couldn't cast
... metadata: struct<...>
to
{'messages': ..., 'instruction': ..., 'input': ..., 'output': ...}
because column names don't match

Seen on /api/datasets/check-format Tier-1/Tier-2 hub loads when loading via path=<repo_id> so declared Features are applied.

Root cause (Studio)

Several Studio load paths treat all *.json / *.jsonl under a hub snapshot or local directory as training data:

  1. Local/dir resolve (UnslothTrainer._resolve_local_files and worker equivalents) globs:
    • *.json, *.jsonl, *.csv, *.parquet
    • and passes all matches to load_dataset("json", data_files=...)
  2. Hub load via datasets.load_dataset(<repo_id>) lets HF auto-discover files; sidecars like filter_report.json / dataset_manifest.json get included.
  3. Preview check-format Tier-1 historically loaded hub files with declared Features, which can CastError when cards omit nested fields.

Relevant areas (names may vary slightly by version):

  • studio/backend/core/training/trainer.py → _resolve_local_files
  • studio/backend/core/training/worker.py → local dataset file resolution
  • studio/backend/hub/utils/dataset_cache.py → cached_dataset_candidates
  • studio/backend/hub/services/datasets/formatting.py / routes/datasets.py → check-format
  • any shared load_dataset wrapper used by training

Proposed fix

  1. Filter training data files before load_dataset:
    • Always drop known sidecars: filter_report.json, dataset_manifest.json, metadata.json, dataset_info(s).json, state.json, manifest.json, *report*, *manifest*, etc.
    • If any record/columnar files exist (.jsonl, .parquet, .csv, .tsv, .arrow), prefer those and ignore bare non-split .json.
  2. For hub cast/schema errors on incomplete card Features:
    • reload via format builder (json/parquet/…) from concrete data files, or
    • relax plain (non-Image/Audio) declared Features for streaming preview.
  3. Keep split selection (train / val / test) after filtering.

Minimal filter behavior

Present files Should load
train.jsonl, filter_report.json, dataset_manifest.json only train.jsonl
train.jsonl, val.jsonl, test.jsonl those three (or split-selected)
train.json only train.json (split-like bare json still allowed)

Impact

  • Any HF dataset that ships quality reports / manifests / metadata JSON next to SFT jsonl will fail SFT in Studio.
  • Private/curated datasets often include exactly these sidecars.
  • Workaround today: delete/move sidecars from the hub repo or point Studio at a cleaned local folder containing only row files.

Workaround

Until fixed upstream:

  • Keep only row files in the dataset repo/folder used for training (train.jsonl / val.jsonl / test.jsonl), or
  • Move sidecars out of the dataset root (e.g. into reports/) so HF/Studio do not pick them up as data files.

Notes

Happy to test a PR. This looks like a general Studio dataset ingestion robustness issue rather than a model/training-kernel bug.

Activity

  1. Momix-77 commented on Jul 29, 2026

    @Momix-77
    Author

    Closing temporarily — report not ready for public visibility yet. Will reopen/repost when ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions