Skip to content

chore: trim verbose comments added in PR #5416 (commit 12295c1f)#5418

Merged
danielhanchen merged 1 commit into
mainfrom
chore/trim-pr5416-comments
May 14, 2026
Merged

chore: trim verbose comments added in PR #5416 (commit 12295c1f)#5418
danielhanchen merged 1 commit into
mainfrom
chore/trim-pr5416-comments

Conversation

@danielhanchen
Copy link
Copy Markdown
Member

Summary

Trim verbose comments and docstrings added in commit 12295c1 (PR #5416). Strictly comment / docstring trims — no behavior changes.

The original commit added ~200 lines of explanatory prose around the peft + transformers-4.x stub-injection fix. This PR collapses the verbose docstrings and inline comments while preserving the key why-it-exists context.

Files touched

  • unsloth/import_fixes.py: collapse the 32-line peft + transformers-4.x drift header to 10 lines; drop redundant per-stub class docstrings and numbered step comments inside fix_peft_transformers_weight_conversion_import; keep one-line docstrings on helpers + the public entry point.
  • unsloth/_gpu_init.py: collapse the 8-line preamble above fix_peft_transformers_weight_conversion_import() to 4 lines.
  • tests/conftest.py: collapse the 13-line block comment above _apply_unsloth_peft_import_fix_for_tests to 5 lines; tighten three internal comments.

Net diff: 59 added, 210 removed.

Verification

Each of the 3 files was checked with an AST verifier that strips all string-literal docstrings (Module / FunctionDef / AsyncFunctionDef / ClassDef) and compares ast.unparse output against 12295c1. All three reported AST identical after docstring strip — i.e. zero non-comment code changes.

OK   unsloth/import_fixes.py  (AST identical after docstring strip)
OK   unsloth/_gpu_init.py     (AST identical after docstring strip)
OK   tests/conftest.py        (AST identical after docstring strip)

Test plan

  • AST verifier confirms comment-only against 12295c1
  • CI passes

Strictly comment / docstring trims. AST-verified against 12295c1 via
scripts/verify_trim_comment_only.py:

* unsloth/import_fixes.py: collapse the 32-line peft+transformers-4.x
  drift header to 10 lines; remove redundant per-stub docstrings and
  per-step numbered comments inside fix_peft_transformers_weight_
  conversion_import; keep one-line docstrings on helpers + on the
  public entry-point.
* unsloth/_gpu_init.py: collapse the 8-line preamble above
  fix_peft_transformers_weight_conversion_import() to 4 lines.
* tests/conftest.py: collapse the 13-line block comment above
  _apply_unsloth_peft_import_fix_for_tests to 5 lines; tighten three
  internal comments.
@danielhanchen danielhanchen merged commit 6994d07 into main May 14, 2026
28 of 32 checks passed
@danielhanchen danielhanchen deleted the chore/trim-pr5416-comments branch May 14, 2026 11:25
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors and condenses comments and docstrings across several files, including tests/conftest.py, unsloth/_gpu_init.py, and unsloth/import_fixes.py. The changes aim to make the explanations for the peft and transformers compatibility stubs more concise while maintaining the original technical context. No functional code changes were made, and as there were no review comments provided, I have no feedback to provide.

pull Bot pushed a commit to steelburn/unsloth that referenced this pull request May 14, 2026
…nslothai#5422)

scripts/verify_comment_only_diff.py compares a list of changed files
between two git refs and reports whether each diff is strictly comments
or docstrings.

  * .py: parse both revs into AST, strip module / class / function
    docstrings, then compare ast.unparse output. Pure Python comments
    are discarded by ast.parse by construction, so any post-strip diff
    is real code.
  * .yml / .yaml: yaml.safe_load both sides and compare the parsed
    Python object; if scalar values differ, also strip shell comments
    inside any multi-line scalar (i.e. `run: |` script bodies) before
    comparing.

Exit code is 0 if every file is comment-only, 1 otherwise. The script
also prints a tight diff snippet for any FAIL line so a reviewer can
spot the real code change at a glance.

This is what I used to gate the trim PRs unslothai#5418 (this repo) and unslothai#640
(unsloth-zoo). Shipping it under scripts/ so any contributor can
deterministically prove a comment / docstring refactor is truly
comment-only, without manually eyeballing every line of a 4000-line
diff.

Usage:

    python scripts/verify_comment_only_diff.py [--base REF] [--head REF] path ...

Defaults: --base origin/main, --head HEAD. Paths are repo-relative.

Smoke test against the squash-merged PR unslothai#5418 (a real 3-file pure trim):

    git diff --name-only 6994d07~1..6994d07 \
      | xargs python scripts/verify_comment_only_diff.py --base 6994d07~1 --head 6994d07

reports OK for all 3 files.
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