Repository navigation
Trim comments in the Studio backend - #12967
Merged
Merged
Conversation
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. |
This was referenced Oct 7, 2026
Lines like '# ======== <Name>' and '# ── Step N ──' mark where each section starts.
danielhanchen
added a commit
that referenced
this pull request
Oct 26, 2026
Comment trim across `unsloth/`, `unsloth_cli/` and `tests/`. No code changes. | scope | files | comment lines before | after | |---|---|---|---| | unsloth, unsloth_cli, tests (+ av_shapes_baseline.json) | 1377 | 111274 | 46085 (-59%) | Counts include docstrings and are measured against current `main`. Removed: section banners, history notes, comments that restate the code and long multi-paragraph explanations condensed to one line. Kept: transformers / TRL / PEFT / vLLM version workarounds, dtype and upcast ordering, Triton kernel layout, overflow and autotune notes, import-order constraints in `unsloth/__init__.py` and `import_fixes.py`, and anything `rl.py` / `rl_replacements.py` / unsloth_zoo patch through `inspect.getsource` (those patches only target code and string literals, which are unchanged). ## How it was checked - `comment_tools.py check --strict-ext` on every changed file against `main`: the code token stream (AST for Python, lexer/tree-sitter for TS/TSX/JS/shell/PowerShell/YAML/Rust) is identical, so only comments and blank lines changed. String literals are untouched; docstring edits are allowed by `--allow-docstring-edits` and covered below. - Comments that code or tests read as text were kept word for word: source-reading tests (`read_text`, `readFileSync`, regex and fixed-window matches), `inspect.getsource` + replace targets, lint markers (`lint-allow:`, `# allow-slot-clamp:`, `# novermin`, `noqa`, `type: ignore`, `eslint`/`biome-ignore`, `@ts-`), shellcheck/zizmor directives, `#region`/`#requires`, PowerShell help blocks, and the comment blocks that tests require to stay identical between `install.sh`/`studio/setup.sh` and `install.ps1`/`studio/setup.ps1`. - Comments that explain a non-obvious invariant, an ordering constraint, a security decision, an upstream workaround or a magic number were kept or shortened to one line. Narration, history, section banners and restatements of the code were removed. - Every changed region was reviewed a second time for comments that became wrong, misplaced or half-finished after condensing, and those were fixed. - Repo lints: `lint_exec_literals`, `lint_av_shapes` (0 new errors), `lint_risky_loaders`, `lint_no_parallel_clamp`, `lint_no_duplicate_ts_imports`, `lint_workflow_triggers`, `lint_backend_python_floor` all pass; `scripts/run_ruff_format.py` is a fixed point; `scripts/sync_shared_ps1_helpers.py --check` reports no drift. - Tests, `main` vs `main` plus all four of these PRs, same machine: the pytest suites (`tests/`, `studio/backend/tests/`, `unsloth_cli/tests/`), the full frontend `node --test` suite and all 133 `tests/**/*.ps1` / `tests/sh/*.sh` scripts. No test fails with these changes that passes on `main` (the few one-off differences either pass on both trees or fail on both when rerun alone). ## Related One of four comment-trim PRs split by area so each diff stays reviewable: #12966 (Studio frontend and Tauri), #12967 (Studio backend), #12968 (unsloth, unsloth_cli, tests), #12969 (installers, scripts, CI). They touch disjoint files (apart from one entry each in `scripts/av_shapes_baseline.json` for #12967 and #12968); the test runs above were on all four applied together. ## Update: merged with main, second pass - Merged current `main`. Where hunks conflicted, the merge took `main`'s side, so the branch still differs from `main` only in comments (`comment_tools.py check --strict-ext` against the new merge base passes). - Tests that landed on `main` after the first pass read some of the removed comments as anchors, so those comments are back: comments in `tests/kaggle/studio_gpu/run_studio_gpu.py`, `tests/studio/studiobench/__main__.py`, `tests/studio/playwright_chat_ui.py` and `tests/studio/playwright_mac_tab_capabilities.py` that four tests read by text. - Second pass on docstrings in `tests/` and `unsloth_cli/tests/`: multi-line test docstrings collapsed to one line (about 4.7k). Library docstrings in `unsloth/` are unchanged. One `scripts/av_shapes_baseline.json` entry recorded a docstring that no longer names the flagged construct, so it is dropped (`lint_av_shapes` reports a baseline entry that allows more than the code has as stale). - Every one-line rewrite was compared against the text it replaced, looking for a dropped `not`, a reversed condition, a wrong identifier or a torn sentence. About 240 were corrected. - Rechecked against `main` on the same machine during this pass (affected tests rerun after the last fixes): the full `tests/` + `unsloth_cli/tests/` pytest run, `studio/backend/tests` and `hub/tests`, the full frontend `node --test` suite, all `tests/sh/*.sh` and the standalone `tests/**/*.ps1` scripts. The remaining differences from `main` are pytest-timeout expiries and wall-clock assertions under heavy parallel load; every other difference was rerun alone and matches `main`. `lint_av_shapes`, `lint_exec_literals` and `lint_risky_loaders` pass. - #12967 and #12968 each drop a different entry from `scripts/av_shapes_baseline.json`; the two hunks do not overlap. ## Comment accuracy audit - Every comment this PR rewrote (rather than deleted) was compared against the text it replaced, one before/after pair at a time, looking for a dropped `not`, a reversed condition, a wrong identifier, a torn sentence or a pointer to a comment that no longer exists. Each proposed correction got a second, independent check against the original before it was applied. - The corrections that passed are in the "Correct shortened comments that lost or changed meaning" commit. Corrections whose before/after pairing was ambiguous, or that would have touched a line with code on it, were left out. - The commit is comment-only (`comment_tools.py check --strict-ext`), no marker a test or regex reads went missing, and the full Python, backend and frontend suites match `main` apart from wall-clock assertions under parallel load that pass when rerun alone. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen
added a commit
that referenced
this pull request
Oct 26, 2026
Comment trim across the installer helpers and repo tooling: the `studio/install_*` helpers, `scripts/`, `.github/`, `docker/` and `pyproject.toml`. No code changes. The installer entry scripts (`install.sh`, `install.ps1`, `studio/setup.sh`, `studio/setup.ps1`, `scripts/uninstall.sh`, `scripts/uninstall.ps1`) moved to #15333 and are identical to `main` here. | scope | files | comment lines before | after | |---|---|---|---| | installers, scripts, CI, docker | 228 | 38524 | 18625 (-52%) | Counts include docstrings and are measured against current `main`. Installer-specific care: - The comment blocks and PowerShell functions that tests require to be identical between `install.sh` and `studio/setup.sh`, and between `install.ps1` and `studio/setup.ps1`, are still identical (all 87 shared PowerShell functions compared through the PowerShell AST, and `sync_shared_ps1_helpers.py --check` is clean). - Comments that `tests/sh` scripts use as `sed`/`awk` anchors are kept word for word. - `lint_av_shapes` hashes whole lines, so trailing comments on installer lines were left alone and no reworded comment introduces scanner keywords. - The pyproject comment above the `windows` extra still names `unsloth[cu130-torch2100]` and `unsloth[cu128-torch2100]`, which `test_windows_xformers_wheel_match.py` requires. - Workflow YAML only lost comments; `lint_workflow_triggers` passes and `uses:` lines are untouched. ## How it was checked - `comment_tools.py check --strict-ext` on every changed file against `main`: the code token stream (AST for Python, lexer/tree-sitter for TS/TSX/JS/shell/PowerShell/YAML/Rust) is identical, so only comments and blank lines changed. Docstrings and string literals are untouched. - Comments that code or tests read as text were kept word for word: source-reading tests (`read_text`, `readFileSync`, regex and fixed-window matches), `inspect.getsource` + replace targets, lint markers (`lint-allow:`, `# allow-slot-clamp:`, `# novermin`, `noqa`, `type: ignore`, `eslint`/`biome-ignore`, `@ts-`), shellcheck/zizmor directives, `#region`/`#requires`, PowerShell help blocks, and the comment blocks that tests require to stay identical between `install.sh`/`studio/setup.sh` and `install.ps1`/`studio/setup.ps1`. - Comments that explain a non-obvious invariant, an ordering constraint, a security decision, an upstream workaround or a magic number were kept or shortened to one line. Narration, history, section banners and restatements of the code were removed. - Every changed region was reviewed a second time for comments that became wrong, misplaced or half-finished after condensing, and those were fixed. - Repo lints: `lint_exec_literals`, `lint_av_shapes` (0 new errors), `lint_risky_loaders`, `lint_no_parallel_clamp`, `lint_no_duplicate_ts_imports`, `lint_workflow_triggers`, `lint_backend_python_floor` all pass; `scripts/run_ruff_format.py` is a fixed point; `scripts/sync_shared_ps1_helpers.py --check` reports no drift. - Tests, `main` vs `main` plus all four of these PRs, same machine: the pytest suites (`tests/`, `studio/backend/tests/`, `unsloth_cli/tests/`), the full frontend `node --test` suite and all 133 `tests/**/*.ps1` / `tests/sh/*.sh` scripts. No test fails with these changes that passes on `main` (the few one-off differences either pass on both trees or fail on both when rerun alone). ## Related One of four comment-trim PRs split by area so each diff stays reviewable: #12966 (Studio frontend and Tauri), #12967 (Studio backend), #12968 (unsloth, unsloth_cli, tests), #12969 (installers, scripts, CI). They touch disjoint files (apart from one entry each in `scripts/av_shapes_baseline.json` for #12967 and #12968); the test runs above were on all four applied together. ## Update: merged with main, second pass - Merged current `main`. Where hunks conflicted, the merge took `main`'s side, so the branch still differs from `main` only in comments (`comment_tools.py check --strict-ext` against the new merge base passes). - `install.ps1` keeps the comment opening `# A redirected stdout is not a console` above the VT early return: `test_windows_setup_output_encoding.py` (Windows, PowerShell 5.1 only) slices the probe on that line. - Rechecked against `main` on the same machine during this pass (affected tests rerun after the last fixes): the full `tests/` + `unsloth_cli/tests/` pytest run, `studio/backend/tests` and `hub/tests`, the full frontend `node --test` suite, all `tests/sh/*.sh` and the standalone `tests/**/*.ps1` scripts. The remaining differences from `main` are pytest-timeout expiries and wall-clock assertions under heavy parallel load; every other difference was rerun alone and matches `main`. `lint_av_shapes`, `lint_exec_literals` and `lint_risky_loaders` pass. ## Comment accuracy audit - Every comment this PR rewrote (rather than deleted) was compared against the text it replaced, one before/after pair at a time, looking for a dropped `not`, a reversed condition, a wrong identifier, a torn sentence or a pointer to a comment that no longer exists. Each proposed correction got a second, independent check against the original before it was applied. - The corrections that passed are in the "Correct shortened comments that lost or changed meaning" commit. Corrections whose before/after pairing was ambiguous, or that would have touched a line with code on it, were left out. - The commit is comment-only (`comment_tools.py check --strict-ext`), no marker a test or regex reads went missing, and the full Python, backend and frontend suites match `main` apart from wall-clock assertions under parallel load that pass when rerun alone. ## Update: installer entry scripts split out - `install.sh`, `install.ps1`, `studio/setup.sh`, `studio/setup.ps1`, `scripts/uninstall.sh` and `scripts/uninstall.ps1` now match `main` in this PR; their trim lives in #15333. The installer-specific notes above about those files apply to #15333. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Oct 26, 2026
Comment trim across the Studio frontend (`studio/frontend`) and the
Tauri desktop shell (`studio/src-tauri`). No code changes.
| scope | files | comment lines before | after |
|---|---|---|---|
| studio/frontend + studio/src-tauri | 2112 | 65273 | 23027 (-65%) |
Counts include docstrings and are measured against current `main`.
Comment share of non-blank lines goes from 10.1% to 3.7%. Removed: JSX
`{/* section */}` labels, comments that restate the next line, history
notes and long explanations that the code or names already carry. Kept:
the reasons behind non-obvious state handling, race and ordering notes,
platform quirks (WebView2, macOS, Linux), security notes in the Tauri
commands, and every comment a frontend or Python contract test reads.
Rust files were checked with doc comments stripped so `///` and `//!`
edits are covered too.
## How it was checked
- `comment_tools.py check --strict-ext` on every changed file against
`main`: the code token stream (AST for Python, lexer/tree-sitter for
TS/TSX/JS/shell/PowerShell/YAML/Rust) is identical, so only comments and
blank lines changed. Docstrings and string literals are untouched.
- Comments that code or tests read as text were kept word for word:
source-reading tests (`read_text`, `readFileSync`, regex and
fixed-window matches), `inspect.getsource` + replace targets, lint
markers (`lint-allow:`, `# allow-slot-clamp:`, `# novermin`, `noqa`,
`type: ignore`, `eslint`/`biome-ignore`, `@ts-`), shellcheck/zizmor
directives, `#region`/`#requires`, PowerShell help blocks, and the
comment blocks that tests require to stay identical between
`install.sh`/`studio/setup.sh` and `install.ps1`/`studio/setup.ps1`.
- Comments that explain a non-obvious invariant, an ordering constraint,
a security decision, an upstream workaround or a magic number were kept
or shortened to one line. Narration, history, section banners and
restatements of the code were removed.
- Every changed region was reviewed a second time for comments that
became wrong, misplaced or half-finished after condensing, and those
were fixed.
- Repo lints: `lint_exec_literals`, `lint_av_shapes` (0 new errors),
`lint_risky_loaders`, `lint_no_parallel_clamp`,
`lint_no_duplicate_ts_imports`, `lint_workflow_triggers`,
`lint_backend_python_floor` all pass; `scripts/run_ruff_format.py` is a
fixed point; `scripts/sync_shared_ps1_helpers.py --check` reports no
drift.
- Tests, `main` vs `main` plus all four of these PRs, same machine: the
pytest suites (`tests/`, `studio/backend/tests/`, `unsloth_cli/tests/`),
the full frontend `node --test` suite and all 133 `tests/**/*.ps1` /
`tests/sh/*.sh` scripts. No test fails with these changes that passes on
`main` (the few one-off differences either pass on both trees or fail on
both when rerun alone).
## Related
One of four comment-trim PRs split by area so each diff stays
reviewable: unslothai#12966 (Studio frontend and Tauri), unslothai#12967 (Studio backend),
unslothai#12968 (unsloth, unsloth_cli, tests), unslothai#12969 (installers, scripts, CI).
They touch disjoint files (apart from one entry each in
`scripts/av_shapes_baseline.json` for unslothai#12967 and unslothai#12968); the test runs
above were on all four applied together.
## Update: merged with main, second pass
- Merged current `main`. Where hunks conflicted, the merge took `main`'s
side, so the branch still differs from `main` only in comments
(`comment_tools.py check --strict-ext` against the new merge base
passes).
- Tests that landed on `main` after the first pass read some of the
removed comments as anchors, so those comments are back:
`chat-adapter.ts` (`// Answered once per thread`),
`prompt-storage-dialog.tsx` (`/** A sidebar row as one markdown
document.`), `use-chat-model-runtime.ts` (`/**\n * Reconcile the UI
after the SERVER unloaded`) and `diffusion-train-panel.tsx` (`// On
first activation`). The first one failed
`chat-export-system-prompt.test.ts`; the other three made `indexOf`
return -1, so their tests kept passing on a slice that ran to the end of
the file.
- Rechecked against `main` on the same machine during this pass
(affected tests rerun after the last fixes): the full `tests/` +
`unsloth_cli/tests/` pytest run, `studio/backend/tests` and `hub/tests`,
the full frontend `node --test` suite, all `tests/sh/*.sh` and the
standalone `tests/**/*.ps1` scripts. The remaining differences from
`main` are pytest-timeout expiries and wall-clock assertions under heavy
parallel load; every other difference was rerun alone and matches
`main`. `lint_av_shapes`, `lint_exec_literals` and `lint_risky_loaders`
pass.
## Comment accuracy audit
- Every comment this PR rewrote (rather than deleted) was compared
against the text it replaced, one before/after pair at a time, looking
for a dropped `not`, a reversed condition, a wrong identifier, a torn
sentence or a pointer to a comment that no longer exists. Each proposed
correction got a second, independent check against the original before
it was applied.
- The corrections that passed are in the "Correct shortened comments
that lost or changed meaning" commit. Corrections whose before/after
pairing was ambiguous, or that would have touched a line with code on
it, were left out.
- The commit is comment-only (`comment_tools.py check --strict-ext`), no
marker a test or regex reads went missing, and the full Python, backend
and frontend suites match `main` apart from wall-clock assertions under
parallel load that pass when rerun alone.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This was referenced Oct 27, 2026
This was referenced Oct 30, 2026
danielhanchen
added a commit
that referenced
this pull request
Nov 9, 2026
…auri (#16109) Condenses the multi-line comments, docstrings and JSDoc / block comments that landed in the Studio frontend (`studio/frontend`) and the Tauri shell (`studio/src-tauri`) after the last cleanup (#12966, #12967, #12968, #12969, #15333, #15594). Same rules as before: every fact a reader needs stays (the reason for a workaround, version bounds, shapes and dtypes, env vars and flags, issue numbers, must / never rules, ordering and security reasons); narration, step-by-step restatement and history go. Informative one-line comments are not touched. No code changes: every changed file has an identical code token stream (and, for Python, an identical AST once docstrings are removed). 109 files, +343 / -582 lines. ## Scope Only sections of 2+ lines whose lines were mostly written after the last cleanup merged. A rewrite is applied only when it saves at least one line, so tight comments are left as they are. Left untouched: - section delimiters, license / SPDX headers, tool directives (`noqa`, `type: ignore`, `eslint-disable`, `@ts-expect-error`, `biome-ignore`, `shellcheck`, `#region`, ...), PowerShell comment-based help, JSX `{/* */}` comments - Python docstrings that can be read at runtime (decorated routes / tools / commands, pydantic models, classes outside tests, anything in a file that reads `__doc__`; module docstrings only where a reader analysis over the whole repo found no reader) - scripts that read their own text back (`$0` / `BASH_SOURCE` / `$PSCommandPath` / `__file__`) - any comment containing a string literal that a test or source-reading script searches for, in a file that reader names (including escaped multi-line literals) - any comment inside a span that a frontend test regex matches in the source it reads - the line `scripts/lint_av_shapes.py` keys its baseline on - helpers that exist in more than one file (the shared `install.ps1` / `studio/setup.ps1` functions, a few Python helpers): every copy keeps the same comments, since tests compare the copies as text ## Verification - `comment_tools.py check --strict-ext --allow-docstring-edits` passes on every changed file (code tokens identical, all languages). - Delimiter and tool-directive comment sequences are identical in every changed file. - `scripts/lint_*.py` (av_shapes, exec_literals, risky_loaders, workflow_triggers, no_parallel_clamp, no_duplicate_ts_imports, duplicate_definitions, backend_python_floor) and `ruff check` give the same result on main and on this branch. - CLI help: every `--help` surface (41 `unsloth` CLI commands, 40 scripts with a parser) is byte-identical to main. - Tests (no GPU), main vs all five round-2 branches together, compared by failing test ID: Studio backend tests that read source text (69,853 tests), root and `unsloth_cli` tests that read source text (41,578 tests), and every frontend node test (14,542 tests). No test fails only on the branch once ordering effects are rerun alone; the real readers this and staging CI turned up (a sidebar layout regex, the av_shapes baseline line, and the test that compares the `install.ps1` / `studio/setup.ps1` helpers) are handled by keeping those comments verbatim. Functions that were identical across files on main (PowerShell, shell, Python) are still identical on the branches. - PowerShell and shell tests that name `install.ps1`, `studio/setup.ps1` or the changed shell test (64 files, run with `pwsh` / `bash`): all pass on main and on the branches. - Each rewrite was reviewed for meaning lost or claims added, removals in files that other files read were checked for readers, and proposed corrections went through a second check; anything flagged without a confirmed correction keeps its original text.
danielhanchen
added a commit
that referenced
this pull request
Nov 9, 2026
…nd CI (#16112) Condenses the multi-line comments, docstrings and JSDoc / block comments that landed in the installer helpers, scripts and CI (`studio/*.py`, `studio/scripts`, `scripts/`, `.github`, `docker`) after the last cleanup (#12966, #12967, #12968, #12969, #15333, #15594). Same rules as before: every fact a reader needs stays (the reason for a workaround, version bounds, shapes and dtypes, env vars and flags, issue numbers, must / never rules, ordering and security reasons); narration, step-by-step restatement and history go. Informative one-line comments are not touched. No code changes: every changed file has an identical code token stream (and, for Python, an identical AST once docstrings are removed). 50 files, +669 / -1,747 lines. ## Scope Only sections of 2+ lines whose lines were mostly written after the last cleanup merged. A rewrite is applied only when it saves at least one line, so tight comments are left as they are. Left untouched: - section delimiters, license / SPDX headers, tool directives (`noqa`, `type: ignore`, `eslint-disable`, `@ts-expect-error`, `biome-ignore`, `shellcheck`, `#region`, ...), PowerShell comment-based help, JSX `{/* */}` comments - Python docstrings that can be read at runtime (decorated routes / tools / commands, pydantic models, classes outside tests, anything in a file that reads `__doc__`; module docstrings only where a reader analysis over the whole repo found no reader) - scripts that read their own text back (`$0` / `BASH_SOURCE` / `$PSCommandPath` / `__file__`) - any comment containing a string literal that a test or source-reading script searches for, in a file that reader names (including escaped multi-line literals) - any comment inside a span that a frontend test regex matches in the source it reads - the line `scripts/lint_av_shapes.py` keys its baseline on - helpers that exist in more than one file (the shared `install.ps1` / `studio/setup.ps1` functions, a few Python helpers): every copy keeps the same comments, since tests compare the copies as text ## Verification - `comment_tools.py check --strict-ext --allow-docstring-edits` passes on every changed file (code tokens identical, all languages). - Delimiter and tool-directive comment sequences are identical in every changed file. - `scripts/lint_*.py` (av_shapes, exec_literals, risky_loaders, workflow_triggers, no_parallel_clamp, no_duplicate_ts_imports, duplicate_definitions, backend_python_floor) and `ruff check` give the same result on main and on this branch. - CLI help: every `--help` surface (41 `unsloth` CLI commands, 40 scripts with a parser) is byte-identical to main. - Tests (no GPU), main vs all five round-2 branches together, compared by failing test ID: Studio backend tests that read source text (69,853 tests), root and `unsloth_cli` tests that read source text (41,578 tests), and every frontend node test (14,542 tests). No test fails only on the branch once ordering effects are rerun alone; the real readers this and staging CI turned up (a sidebar layout regex, the av_shapes baseline line, and the test that compares the `install.ps1` / `studio/setup.ps1` helpers) are handled by keeping those comments verbatim. Functions that were identical across files on main (PowerShell, shell, Python) are still identical on the branches. - PowerShell and shell tests that name `install.ps1`, `studio/setup.ps1` or the changed shell test (64 files, run with `pwsh` / `bash`): all pass on main and on the branches. - Each rewrite was reviewed for meaning lost or claims added, removals in files that other files read were checked for readers, and proposed corrections went through a second check; anything flagged without a confirmed correction keeps its original text.
danielhanchen
added a commit
that referenced
this pull request
Nov 9, 2026
Condenses the multi-line comments, docstrings and JSDoc / block comments that landed in the Studio backend (`studio/backend`) after the last cleanup (#12966, #12967, #12968, #12969, #15333, #15594). Same rules as before: every fact a reader needs stays (the reason for a workaround, version bounds, shapes and dtypes, env vars and flags, issue numbers, must / never rules, ordering and security reasons); narration, step-by-step restatement and history go. Informative one-line comments are not touched. No code changes: every changed file has an identical code token stream (and, for Python, an identical AST once docstrings are removed). 922 files, +5,663 / -11,400 lines. ## Scope Only sections of 2+ lines whose lines were mostly written after the last cleanup merged. A rewrite is applied only when it saves at least one line, so tight comments are left as they are. Left untouched: - section delimiters, license / SPDX headers, tool directives (`noqa`, `type: ignore`, `eslint-disable`, `@ts-expect-error`, `biome-ignore`, `shellcheck`, `#region`, ...), PowerShell comment-based help, JSX `{/* */}` comments - Python docstrings that can be read at runtime (decorated routes / tools / commands, pydantic models, classes outside tests, anything in a file that reads `__doc__`; module docstrings only where a reader analysis over the whole repo found no reader) - scripts that read their own text back (`$0` / `BASH_SOURCE` / `$PSCommandPath` / `__file__`) - any comment containing a string literal that a test or source-reading script searches for, in a file that reader names (including escaped multi-line literals) - any comment inside a span that a frontend test regex matches in the source it reads - the line `scripts/lint_av_shapes.py` keys its baseline on - helpers that exist in more than one file (the shared `install.ps1` / `studio/setup.ps1` functions, a few Python helpers): every copy keeps the same comments, since tests compare the copies as text ## Verification - `comment_tools.py check --strict-ext --allow-docstring-edits` passes on every changed file (code tokens identical, all languages). - Delimiter and tool-directive comment sequences are identical in every changed file. - `scripts/lint_*.py` (av_shapes, exec_literals, risky_loaders, workflow_triggers, no_parallel_clamp, no_duplicate_ts_imports, duplicate_definitions, backend_python_floor) and `ruff check` give the same result on main and on this branch. - CLI help: every `--help` surface (41 `unsloth` CLI commands, 40 scripts with a parser) is byte-identical to main. - Tests (no GPU), main vs all five round-2 branches together, compared by failing test ID: Studio backend tests that read source text (69,853 tests), root and `unsloth_cli` tests that read source text (41,578 tests), and every frontend node test (14,542 tests). No test fails only on the branch once ordering effects are rerun alone; the real readers this and staging CI turned up (a sidebar layout regex, the av_shapes baseline line, and the test that compares the `install.ps1` / `studio/setup.ps1` helpers) are handled by keeping those comments verbatim. Functions that were identical across files on main (PowerShell, shell, Python) are still identical on the branches. - PowerShell and shell tests that name `install.ps1`, `studio/setup.ps1` or the changed shell test (64 files, run with `pwsh` / `bash`): all pass on main and on the branches. - Each rewrite was reviewed for meaning lost or claims added, removals in files that other files read were checked for readers, and proposed corrections went through a second check; anything flagged without a confirmed correction keeps its original text.
danielhanchen
added a commit
that referenced
this pull request
Nov 9, 2026
…16111) Condenses the multi-line comments, docstrings and JSDoc / block comments that landed in the core package (`unsloth/`), the CLI (`unsloth_cli/`) and `tests/` after the last cleanup (#12966, #12967, #12968, #12969, #15333, #15594). Same rules as before: every fact a reader needs stays (the reason for a workaround, version bounds, shapes and dtypes, env vars and flags, issue numbers, must / never rules, ordering and security reasons); narration, step-by-step restatement and history go. Informative one-line comments are not touched. No code changes: every changed file has an identical code token stream (and, for Python, an identical AST once docstrings are removed). 437 files, +2,397 / -4,483 lines. ## Scope Only sections of 2+ lines whose lines were mostly written after the last cleanup merged. A rewrite is applied only when it saves at least one line, so tight comments are left as they are. Left untouched: - section delimiters, license / SPDX headers, tool directives (`noqa`, `type: ignore`, `eslint-disable`, `@ts-expect-error`, `biome-ignore`, `shellcheck`, `#region`, ...), PowerShell comment-based help, JSX `{/* */}` comments - Python docstrings that can be read at runtime (decorated routes / tools / commands, pydantic models, classes outside tests, anything in a file that reads `__doc__`; module docstrings only where a reader analysis over the whole repo found no reader) - scripts that read their own text back (`$0` / `BASH_SOURCE` / `$PSCommandPath` / `__file__`) - any comment containing a string literal that a test or source-reading script searches for, in a file that reader names (including escaped multi-line literals) - any comment inside a span that a frontend test regex matches in the source it reads - the line `scripts/lint_av_shapes.py` keys its baseline on - the derivation, diagram and tuning-table comments in `unsloth/kernels` (the cross entropy loss math, num_warps tables, fitted fused-vs-dense thresholds, GEMV config notes) - helpers that exist in more than one file (the shared `install.ps1` / `studio/setup.ps1` functions, a few Python helpers): every copy keeps the same comments, since tests compare the copies as text ## Verification - `comment_tools.py check --strict-ext --allow-docstring-edits` passes on every changed file (code tokens identical, all languages). - Delimiter and tool-directive comment sequences are identical in every changed file. - `scripts/lint_*.py` (av_shapes, exec_literals, risky_loaders, workflow_triggers, no_parallel_clamp, no_duplicate_ts_imports, duplicate_definitions, backend_python_floor) and `ruff check` give the same result on main and on this branch. - CLI help: every `--help` surface (41 `unsloth` CLI commands, 40 scripts with a parser) is byte-identical to main. - Tests (no GPU), main vs all five round-2 branches together, compared by failing test ID: Studio backend tests that read source text (69,853 tests), root and `unsloth_cli` tests that read source text (41,578 tests), and every frontend node test (14,542 tests). No test fails only on the branch once ordering effects are rerun alone; the real readers this and staging CI turned up (a sidebar layout regex, the av_shapes baseline line, and the test that compares the `install.ps1` / `studio/setup.ps1` helpers) are handled by keeping those comments verbatim. Functions that were identical across files on main (PowerShell, shell, Python) are still identical on the branches. - PowerShell and shell tests that name `install.ps1`, `studio/setup.ps1` or the changed shell test (64 files, run with `pwsh` / `bash`): all pass on main and on the branches. - Each rewrite was reviewed for meaning lost or claims added, removals in files that other files read were checked for readers, and proposed corrections went through a second check; anything flagged without a confirmed correction keeps its original text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comment trim across the Studio backend (
studio/backend), including its tests. No code changes.Counts include docstrings and are measured against current
main.Removed: section banners, narration of the next statement, history and issue-number notes, and long paragraphs condensed to the one line that matters. Kept: sandbox and path-safety reasoning, process and GPU lifecycle ordering, llama.cpp / sd.cpp / vLLM version quirks, the origins of magic numbers, and every comment that a test or
inspect.getsourcepatch matches.scripts/av_shapes_baseline.jsondrops one entry: the twotools.pycomments it recorded no longer exist, so the entry was stale.How it was checked
comment_tools.py check --strict-exton every changed file againstmain: the code token stream (AST for Python, lexer/tree-sitter for TS/TSX/JS/shell/PowerShell/YAML/Rust) is identical, so only comments and blank lines changed. String literals are untouched; docstring edits are allowed by--allow-docstring-editsand covered below.read_text,readFileSync, regex and fixed-window matches),inspect.getsource+ replace targets, lint markers (lint-allow:,# allow-slot-clamp:,# novermin,noqa,type: ignore,eslint/biome-ignore,@ts-), shellcheck/zizmor directives,#region/#requires, PowerShell help blocks, and the comment blocks that tests require to stay identical betweeninstall.sh/studio/setup.shandinstall.ps1/studio/setup.ps1.lint_exec_literals,lint_av_shapes(0 new errors),lint_risky_loaders,lint_no_parallel_clamp,lint_no_duplicate_ts_imports,lint_workflow_triggers,lint_backend_python_floorall pass;scripts/run_ruff_format.pyis a fixed point;scripts/sync_shared_ps1_helpers.py --checkreports no drift.mainvsmainplus all four of these PRs, same machine: the pytest suites (tests/,studio/backend/tests/,unsloth_cli/tests/), the full frontendnode --testsuite and all 133tests/**/*.ps1/tests/sh/*.shscripts. No test fails with these changes that passes onmain(the few one-off differences either pass on both trees or fail on both when rerun alone).Related
One of four comment-trim PRs split by area so each diff stays reviewable: #12966 (Studio frontend and Tauri), #12967 (Studio backend), #12968 (unsloth, unsloth_cli, tests), #12969 (installers, scripts, CI). They touch disjoint files (apart from one entry each in
scripts/av_shapes_baseline.jsonfor #12967 and #12968); the test runs above were on all four applied together.Update: merged with main, second pass
main. Where hunks conflicted, the merge tookmain's side, so the branch still differs frommainonly in comments (comment_tools.py check --strict-extagainst the new merge base passes).mainafter the first pass read some of the removed comments as anchors, so those comments are back: the# ========== AUDIO MODELS: custom preprocessing ==========banner intrainer.py, the1g. ROCm OOM guardand2b. Training VRAM budgetbanners inworker.py, a[CALL_ID]comment intool_healing.py, and the_guard_peft_torchao_dispatcherdocstring, whichtest_diffusion_peft_torchao_guard.pycompares by AST against its copy inunsloth/import_fixes.py.llama_compat.py(it registers routes without decorators), and any file that reads__doc__.not, a reversed condition, a wrong identifier or a torn sentence. About 240 were corrected.mainon the same machine during this pass (affected tests rerun after the last fixes): the fulltests/+unsloth_cli/tests/pytest run,studio/backend/testsandhub/tests, the full frontendnode --testsuite, alltests/sh/*.shand the standalonetests/**/*.ps1scripts. The remaining differences frommainare pytest-timeout expiries and wall-clock assertions under heavy parallel load; every other difference was rerun alone and matchesmain.lint_av_shapes,lint_exec_literalsandlint_risky_loaderspass.scripts/av_shapes_baseline.json; the two hunks do not overlap.Comment accuracy audit
not, a reversed condition, a wrong identifier, a torn sentence or a pointer to a comment that no longer exists. Each proposed correction got a second, independent check against the original before it was applied.comment_tools.py check --strict-ext), no marker a test or regex reads went missing, and the full Python, backend and frontend suites matchmainapart from wall-clock assertions under parallel load that pass when rerun alone.