Skip to content

Trim comments in the installers, scripts and CI config - #12969

Merged
danielhanchen merged 79 commits into
mainfrom
trim-comments-installers-scripts
Oct 26, 2026
Merged

danielhanchen merged 79 commits into
mainfrom
trim-comments-installers-scripts

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-07T15:42:01.753783Z e106554 PR opened
🔒 Security Review ⚠️ Failed 2026-10-07T15:42:02.095474Z e106554 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-07T15:42:01.753783Z e106554 PR opened
🔒 Security Review ⚠️ Failed 2026-10-07T15:42:02.095474Z e106554 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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>
install.sh, install.ps1, studio/setup.sh, studio/setup.ps1 and scripts/uninstall.{sh,ps1} go back to main here.

[skip ci]
danielhanchen added a commit that referenced this pull request Oct 26, 2026
Comment trim across the Studio backend (`studio/backend`), including its
tests. No code changes.

| scope | files | comment lines before | after |
|---|---|---|---|
| studio/backend (+ av_shapes_baseline.json) | 1883 | 185225 | 72964
(-61%) |

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.getsource` patch matches.

`scripts/av_shapes_baseline.json` drops one entry: the two `tools.py`
comments it recorded no longer exist, so the entry was stale.

## 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: the `#
========== AUDIO MODELS: custom preprocessing ==========` banner in
`trainer.py`, the `1g. ROCm OOM guard` and `2b. Training VRAM budget`
banners in `worker.py`, a `[CALL_ID]` comment in `tool_healing.py`, and
the `_guard_peft_torchao_dispatcher` docstring, which
`test_diffusion_peft_torchao_guard.py` compares by AST against its copy
in `unsloth/import_fixes.py`.
- Second pass on docstrings: multi-line docstrings of backend functions
and tests collapsed to one line, or deleted where they only restated the
name (about 8k docstrings). Left alone: route handlers and every other
decorated function, classes (pydantic models feed the OpenAPI schema),
module docstrings outside tests, `llama_compat.py` (it registers routes
without decorators), and any file that reads `__doc__`.
- 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
danielhanchen merged commit 3c812a3 into main Oct 26, 2026
@danielhanchen
danielhanchen deleted the trim-comments-installers-scripts branch October 26, 2026 09:55
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 26, 2026
Comment trim for the installer entry scripts, split out of unslothai#12969 so
they can be reviewed on their own: `install.sh`, `install.ps1`,
`studio/setup.sh`, `studio/setup.ps1`, `scripts/uninstall.sh` and
`scripts/uninstall.ps1`. No code changes.

## 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 four
files move together in this PR, so they stay in lockstep, and
`scripts/sync_shared_ps1_helpers.py --check` is clean.
- Comments that `tests/sh` scripts and Python tests use as
`sed`/`awk`/slice anchors are kept word for word. That includes the `# A
redirected stdout is not a console` line in `install.ps1`, which
`test_windows_setup_output_encoding.py` slices on.
- `lint_av_shapes` hashes whole lines, so trailing comments on installer
lines were left alone.

## How it was checked

- `comment_tools.py check --strict-ext` on all six files against `main`:
the code token stream (lexer + tree-sitter for shell, the PowerShell
parser for `.ps1`) is identical, so only comments and blank lines
changed.
- Tests, `main` vs this branch at the same `main` commit: every pytest
file under `tests/`, `studio/backend/tests` and `unsloth_cli/tests` that
references one of these scripts, plus every `tests/**/*.sh` /
`tests/**/*.ps1` script that does. Failing test IDs match `main`:
backend 6 failed / 3119 passed on both sides, and the root run differs
by one ROCm install test that passes 3/3 alone on both. Shell/PowerShell
exit codes match apart from `test_nvidia_python_probe_parity.ps1`, whose
`live:` checks are intermittent on `main` too (6/12 failing runs on
`main`, 3/12 here).

## Related

unslothai#12969 keeps the rest of the installers/scripts/CI trim; these six files
are back to `main` there.
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>
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.
danielhanchen added a commit that referenced this pull request Nov 24, 2026
… again (#19245)

## Keep scan_packages.py clear of Bitdefender's Python stealer signature
again

`scripts/scan_packages.py` on main is flagged again on VirusTotal as
`Generic.PY.STEALER.B`, the same detection #12169 fixed in September.
Bitdefender, and every engine that ships its signatures, quarantines the
file on a contributor's machine.

### What changed

Comments only. The comment trim in #12969 shortened several comment
blocks near the top of the file; that is what brought the detection
back. This restores those comments (the 28 edits above the anti-analysis
patterns) and keeps the rest of the trim. The parsed code is identical
to main (same `ast.dump`), so behaviour does not change.

One line is added above `_joined` noting that trimming the comments
there re-triggered it, so the next cleanup rescans the file.

### Evidence (VirusTotal, fresh uploads, 2026-11-24)

| Version of `scripts/scan_packages.py` | Detections |
|---|---|
| After #12169 (Sep 27) and after #12884 (Oct 6) | 0 |
| After #12969 (Oct 26) | 8: ALYac, Arcabit, BitDefender, Emsisoft,
GData, MicroWorld-eScan, VIPRE `Generic.PY.STEALER.B`; CTX
`script.spyware.generic` |
| main today (after #16112) | the same 8 |
| main with the top 28 comment edits reverted | 0 |
| This PR | 0 / 72 (sha256
`29cb47f1b33b57815d75a1a76476c53b068ce452068c8569d10ea2f949b968af`) |

Bisecting the 110 comment edits between #12884 and main: applying only
edits 55 to 110 stays clean, while several small subsets of edits 0 to
21 each bring the detection back on their own. The detection reacts to
how much comment text separates the pattern tables near the top of the
file, not to any single word.

### Tests

- `tests/security/test_scan_packages.py`,
`tests/security/test_lint_av_shapes.py`,
`tests/test_scripts_write_lf.py`: 181 passed.
- `scripts/lint_av_shapes.py`: 0 new errors. Pre-commit ruff clean.

### Not covered

- Engines can change their signatures at any time; this is clean against
today's.
- Other files were not affected: the installers, setup scripts,
uninstallers, `studio/install_*.py` helpers and `scan_npm_packages.py`
on main are all 0 detections today.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants