Repository navigation
CPU backend: export load_ebook_dataset, RawTextDataLoader and TextPreprocessor - #15501
Conversation
…processor The GPU backend exports them from unsloth; the CPU backend (#14717) did not, so 'from unsloth import load_ebook_dataset' raised ImportError on CPU-only hosts. Loaded by file so dataprep/__init__ (synthetic.py needs a GPU device type) never runs.
Codex Review SummaryThis 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 |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
Both lint reds here come from one PR-specific finding: the risky loader baseline.
|
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
…5501 (#15549) `Source lint` and `workflow-trigger lint` (`tests/security/test_lint_risky_loaders.py::test_the_tree_matches_the_baseline`) fail on main since #15501 merged, and so on every PR based after it (e.g. #15536, job 122152574837): ``` 1 risky loader call site(s) not in the baseline: unsloth/_cpu_init.py:205 [dynamic-import] spec_from_file_location ``` #15501 added `_load_dataprep` to the CPU backend init, which loads `unsloth/dataprep/raw_text.py` and `ebooks.py` by file (so it skips `dataprep/__init__`, which needs a GPU device type). The call is safe, but the baseline entry was not recorded before it merged. ## Review - The path is `Path(__file__).resolve().parent / "dataprep" / f"{name}.py"`, inside the installed package. - The only callers pass the constants `"raw_text"` and `"ebooks"`, and `_load_dataprep` is deleted right after, so nothing else can reach it. - This is the same shape as the existing `unsloth/__init__.py` entry that loads `dataprep/ebooks.py` by file on MLX. ## Change One entry from `python scripts/lint_risky_loaders.py --update`, with the reason filled in. Nothing else in the baseline moves. ## Verification - `python scripts/lint_risky_loaders.py`: main reports the site above and exits 1; this branch prints `ok: 111 risky loader call site(s), all recorded`. - `tests/security/test_lint_risky_loaders.py`: main 1 failed, 45 passed; this branch 46 passed. - The entry is digest-pinned to the call: changing its path argument to `os.environ["X_DATAPREP"]` reopens the site and the lint exits 1 again.
On a host without an accelerator,
import unslothhands off to the CPU backend (unsloth/_cpu_init.py, #14717). The GPU backend exports the dataprep helpers fromunsloth(_gpu_init.py), but the CPU backend did not. So the documentedfrom unsloth import load_ebook_dataset(#14453) raisesImportError: cannot import name 'load_ebook_dataset'on CPU-only hosts, and so doRawTextDataLoaderandTextPreprocessor.The CPU backend now exports all three. It loads
dataprep/raw_text.pyanddataprep/ebooks.pyby file, the way the MLX backend already does, becausedataprep/__init__also importssynthetic.py, which needs a GPU device type. Neither file has relative imports.test_cpu_backend_init.py::test_no_accelerator_loads_the_cpu_backendnow also checks the three names in its no-accelerator subprocess probe. The GPU-only module list it asserts against is unchanged.test_cpu_backend_init.py(CUDA hidden)