Repository navigation
CPU backend: UNSLOTH_MEMORY_REPORT reports host RAM - #18807
Conversation
Codex Review Summary: ✅ CompletedThis 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b37832bd3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…e over the cgroup and its ancestors [skip ci]
|
@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". |
# Conflicts: # tests/test_run_report.py [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
…18846) ## Summary `Source lint` (Lint CI) and the risky loader test in `workflow-trigger lint` are red on `main` since #18807, and on every PR based after it (#18840, #18841): ``` 1 risky loader call site(s) not in the baseline: unsloth/_cpu_init.py:54 [dynamic-import] spec_from_file_location ``` #18807 (`UNSLOTH_MEMORY_REPORT` reports host RAM on the CPU backend) loads `unsloth/utils/run_report.py` with `importlib.util.spec_from_file_location` instead of importing `unsloth.utils`, because that package's `__init__` pulls in the GPU model stack the CPU route skips. The path is fixed, relative to `_cpu_init.py` inside the installed package, so nothing external chooses what gets executed. The call is fine and only needs recording. ## Fix `python scripts/lint_risky_loaders.py --update`, with the new entry's reason filled in. ## Testing - `python scripts/lint_risky_loaders.py`: all 124 call sites recorded (exits 1 on `main`). - `tests/security/test_lint_risky_loaders.py`: 46 passed.
…rd red on main) (#18850) ## Summary `Repo tests (CPU, rest-2)` is red on `main` since #18807: ``` tests/test_source_read_encoding.py::test_checked_in_file_reads_name_an_encoding[0] AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding, so they break on Windows as soon as that file gains a non-ASCII byte. Pass encoding = "utf-8": ['tests/test_run_report.py:307: read_text()'] ``` #18807 added `test_cpu_memory_report_wired_on_cpu_route`, which reads `unsloth/_cpu_init.py` with a bare `read_text()`. The guard is right: on Windows that decodes with the locale code page, so the test breaks as soon as the file gains a non-ASCII character. ## Fix `read_text(encoding = "utf-8")`. ## Testing - `tests/test_source_read_encoding.py`: fails on `main` with the site above, passes with this change. - `tests/test_run_report.py::test_cpu_memory_report_wired_on_cpu_route`: passes.
UNSLOTH_MEMORY_REPORT=1only looked at CUDA devices, so on the CPU backend it printed nothing. CPU training is mostly bounded by RAM, so the same stages now report the process RSS, its peak and the RAM still available:Changes
unsloth/utils/run_report.py:cpu_memory_snapshot()(Linux/proc/self/statusVmRSS / VmHWM and/proc/meminfoMemAvailable, total capped by a cgroup v2memory.max; psutil on macOS / Windows;ru_maxrssas the peak fallback).report_memory(..., cpu = True)andinstall_memory_report(trainer, cpu = True)print the host line. The GPU route calls are unchanged: stillreport_memory(stage, owner)with no new keyword.unsloth/_cpu_init.py: reports atFastLanguageModel.from_pretrainedand installs the first-forward / first-optimizer-step hooks on CPU SFTTrainer / UnslothTrainer init.run_report.pyis loaded by file becauseunsloth.utilsimports the GPU model stack. Off unlessUNSLOTH_MEMORY_REPORTis set.Tests
tests/test_run_report.py: the snapshot is sane (rss <= peak, available <= total), the cpu line prints once per (stage, owner), nothing about the host is printed withoutcpu = True, and_cpu_init.pywires it without importingunsloth.utils. The existing end-to-end test still sees the GPU route's two-argument calls.tests/test_run_report.py: 16 passed (2 of them new, and those fail on main). The CPU test files (test_cpu_backend_init,test_cpu_backend_tiled_mlp,test_fused_head_cpu_dispatch,test_gc_every_n_cpu_route,test_cpu_route_context_parallel) give the same result as main: one failure that main has too,test_fused_head_cpu_dispatch.py::test_cpu_dispatch_keeps_trl_output_count.Independent of the unsloth-zoo CPU PRs (threads, memory defaults, compile, packing, merged save): it needs no zoo change, and they need none from it.