Skip to content

Trim comments in the installer entry scripts - #15333

Merged
danielhanchen merged 2 commits into
mainfrom
trim-comments-installer-entry
Oct 26, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
trim-comments-installer-entry

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Comment trim for the installer entry scripts, split out of #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

#12969 keeps the rest of the installers/scripts/CI trim; these six files are back to main there.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T07:04:42.720278Z
We couldn’t complete this review. Comment @codex review to try again.
2948b04 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 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
danielhanchen merged commit ac95436 into main Oct 26, 2026
@danielhanchen
danielhanchen deleted the trim-comments-installer-entry branch October 26, 2026 09:56
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant