Skip to content

Restore facts the comment trim cut from the unsloth package - #10328

Merged
danielhanchen merged 1 commit into
mainfrom
restore-facts-10116
Sep 5, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
restore-facts-10116

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The comment trim in #10116 shortened a number of comments in the unsloth package past the point where they still carried the fact that justified the code underneath. This puts those facts back. Comments only: the gate reports code unchanged on all eight files, and a diff of non-comment lines is empty.

Sixteen sites, the ones worth calling out:

  • _gpu_init.py - the guard sits above import unsloth_zoo rather than in the late import-fix block further down, and the trimmed text no longer said why. Restored the placement rationale and the failure that motivated it.
  • import_fixes.py - restored why the default stubs are inert at all: on transformers <5 the whole module is ours and peft's converter never runs. Without it the surviving sentence about a real transformers is a non-sequitur.
  • kernels/utils.py - restored that plain attribute access does not survive a partial bitsandbytes import, which is the entire reason the retry is written import bitsandbytes.functional as bnb_functional.
  • save.py - the cache copy lands wherever the cache is, which need not be the filesystem holding save_directory; HF_HOME on a data volume is the ordinary layout on a machine with more than one disk. The trimmed text had compressed this into "lands wherever HF_HOME points", which is not the same claim. Also restored that each drop message names the filesystem it measured, and that HfApi is the module-level import while hf_hub_download is local.
  • tokenizer_utils.py - the trim folded an # else: note into the preceding elif, where it read as if the branch that sets cache_dir = None also honours a caller-supplied cache_dir. Moved back below the branch with its reason.
  • models/rl.py - the largest group. Restored the literal TRL eval_packing line and why packing beats truncating (wrapped concatenates before chunking, bfd_split splits an overlength example into more chunks; cutting rows at the cap first throws that away), the max_length/packing condition, and the raw-split carve-out that makes the early return True safe. Two commented-out dict entries had been fused into a single prose sentence; both are back on their own lines.
  • models/_utils.py, models/loader_utils.py - the named re-entrant callers, and the conclusion that makes the bare return kwargs safe.

Five further sites flagged by the same scan were false positives, complete sentences that lost nothing, and are untouched.

Every restored claim was checked against the current code rather than copied back from the old text. One stale figure in the original ("roughly 95 lines") was deliberately not restored, since the file has drifted past it.

The trim in #10116 shortened comments past the point where they still
carried the fact that justified the code. Sixteen sites, comments only:

- _gpu_init.py: why the torchaudio guard sits above `import unsloth_zoo`
  rather than in the late import-fix block, and the failure that motivated
  it.
- import_fixes.py: why the default stubs are inert at all, namely that on
  transformers <5 the whole module is ours and peft's converter never runs.
- kernels/utils.py: that plain attribute access does not survive a partial
  bitsandbytes import, which is why the retry uses `import x.y as z`.
- save.py: that the cache copy lands wherever the cache is, which need not
  be the filesystem holding save_directory (HF_HOME on a data volume is the
  ordinary multi-disk layout); that each drop message names the filesystem
  it measured; and that HfApi is the module-level import.
- tokenizer_utils.py: an `# else:` note had been folded into the preceding
  `elif`, where it read as if the branch that sets cache_dir = None also
  honours a caller-supplied cache_dir. Moved back and its reason restored.
- models/rl.py: the TRL eval_packing line and why packing beats truncating,
  the max_length/packing condition, the raw-split carve-out that makes the
  early `return True` safe, and two commented-out dict entries that had been
  fused into one prose sentence.
- models/_utils.py, models/loader_utils.py: the named re-entrant callers and
  the conclusion that makes the bare `return kwargs` safe.

Five other flagged sites were false positives and are untouched. The gate
reports code unchanged on all eight files.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 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 ✅ Completed 2026-09-05T04:40:34.100844Z e585d83 Manual request
ℹ️ 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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 5, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: e585d83ebc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 5, 2026
@danielhanchen
danielhanchen merged commit ca42c01 into main Sep 5, 2026
49 checks passed
@danielhanchen
danielhanchen deleted the restore-facts-10116 branch September 5, 2026 05:12
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