chore: trim verbose comments added in PR #5416 (commit 12295c1f)#5418
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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.
3 tasks
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.
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.
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
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.
Test plan