Repository navigation
Studio: keep JSONL schema recovery working with a UTF-8 BOM - #18015
Conversation
|
@codex review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
#18324) ## Multi-LoRA packing: load the num_proc policy without importing unsloth `studio/backend/tests/test_dataset_map_num_proc.py::test_the_batched_packing_pool_asks_the_same_veto` fails in `(Python 3.13, a-f)` on every PR since #17701, for example #18015, #18108, #18142 and #18303: ``` core/training/multi_lora_trainer.py:686: in _pack_num_proc from unsloth_zoo.dataset_num_proc import get_dataset_num_proc E ModuleNotFoundError: No module named 'unsloth_zoo' core/training/multi_lora_trainer.py:688: in _pack_num_proc from unsloth.dataset_num_proc import get_dataset_num_proc unsloth/_gpu_init.py:241: in <module> E ImportError: Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` then retry! ``` ### Cause `_pack_num_proc`, the multi-LoRA packing pool's worker count from #15733, looks up the shared `dataset_num_proc` policy in two steps: 1. it imports `unsloth_zoo`; 2. if that fails, it falls back to `from unsloth.dataset_num_proc import ...`. That fallback runs the whole `unsloth` package `__init__`, which needs `unsloth_zoo` anyway and patches torch on the way. The rest of the backend already avoids this. `utils.hardware.hardware._shared_policy()` tries `unsloth_zoo` first and otherwise loads the stdlib-only `dataset_num_proc.py` straight off disk, precisely so that no caller runs `import unsloth`. #17701 added the first test that reaches `_pack_num_proc`, and the backend shard runs without `unsloth_zoo`, so the fallback fails there. ### Fix `_pack_num_proc` now gets the policy from `_shared_policy()`, the same loader the single-job tokenize pool uses. - **With a policy**, which is every real install: the call is unchanged, `get_dataset_num_proc(count)` on the same module. - **With no policy at all:** it keeps that function's contract, so a serial count of 1 still means `None`. ### Verification - Faithful repro of the CI state: `core.training.trainer` already imported, then `unsloth_zoo` made unimportable, then `_pack_num_proc` called with a tight host-memory snapshot. - `main`: `ModuleNotFoundError: No module named 'unsloth_zoo'`. - This PR: returns `None`, as the test expects. - With `unsloth_zoo` installed: `tests/test_dataset_map_num_proc.py` and the multi-LoRA tests pass (88 passed). - ruff is clean.
JSONL schema recovery fails when a file starts with a UTF-8 BOM. The ordinary datasets loader accepts that preamble, but when a later block or shard adds a column or message field,
json_rows_featuresrereads the files as plain UTF-8. The BOM reachesjson.loads, the scan returns no schema, and loading ends with the original dataset-generation error. The same rows without a BOM recover normally.Read the schema scan with
utf-8-sig, matching the JSONL loader's handling of the preamble. BOM characters inside training text remain intact, and invalid UTF-8 still prevents schema recovery.Validation on macOS, Python 3.12.9, datasets 4.3.0, PyArrow 21.0.0 and Hugging Face Hub 1.32.0:
unsloth_cli/tests/test_train_vision_dataset.py.git diff --checkpass.These use real local dataset loads; model operations in the CSV and CLI tests are mocked. No model training or GPU run. This verifies JSONL input; datasets 4.3.0 still rejects JSON arrays with a BOM in its own reader.