Skip to content

FSDP2 save: ignore unsloth_zoo's bitsandbytes stub in the Linear4bit checks - #17869

Merged
danielhanchen merged 2 commits into
mainfrom
fsdp2-save-bnb-stub
Nov 15, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fsdp2-save-bnb-stub

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Without bitsandbytes installed, from bitsandbytes.nn import Linear4bit returns unsloth_zoo's stub, which is an instance rather than a class. The FSDP2 save helpers' isinstance(m, Linear4bit) checks then raised TypeError. That broke every full DCP state dict, including Trainer.save_model under FSDP2 / TP, on such hosts. The bug has been on main since #13895.

A small _linear4bit_class() helper now returns the class only when it really is one. The four call sites skip the bitsandbytes handling when it isn't.

  • Flip test tests/test_fsdp2_save_bnb_stub.py: TypeError on main, passes here.
  • Existing tests: test_fsdp2_save_args.py and test_fsdp2_save_coverage.py pass (33 total with the new test).

…checks

Without bitsandbytes, from bitsandbytes.nn import Linear4bit yields the zoo stub's instance, so
isinstance(m, Linear4bit) raised TypeError and every full DCP state dict (Trainer.save_model under
FSDP2 / TP) failed on such hosts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T18:58:12.138618Z fbfcbc3 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: fbfcbc301d

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

[skip ci]
@danielhanchen
danielhanchen merged commit c9f432f into main Nov 15, 2026
@danielhanchen
danielhanchen deleted the fsdp2-save-bnb-stub branch November 15, 2026 22:34
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