Skip to content

FSDP2 optimizer_cls test: follow #15008, which keeps bitsandbytes Adam / AdamW on local shards - #15049

Merged
danielhanchen merged 1 commit into
mainfrom
ci-fsdp2-bnb-cls-contract
Oct 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-fsdp2-bnb-cls-contract

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Repo tests (CPU, fsdp2) fails on main since #15008, for example on #14970 and #15000:

tests/test_fsdp2_native_optim_reentry_gloo.py::test_bnb_optimizer_cls_and_kwargs_is_refused
AssertionError: (0, 'bnb.keyword', {'error': '', 'sharded': True})

Cause

#15008 made native FSDP2 keep a bitsandbytes Adam / AdamW and step each rank's local shard. _refuse_bnb_optimizer_cls now lets optimizer_cls_and_kwargs = (bnb.optim.AdamW8bit, ...) through whenever this bitsandbytes can step local shards, and refuses it otherwise (UNSLOTH_FSDP2_BNB_LOCAL=0). The test still expected every bitsandbytes class to be refused. The product change is intended, as the #15008 description says, so the test was out of date.

Fix

The worker now also reports native._bnb_local_shards_available(), and the test asserts each arm against it:

  • torch.*: accepted and sharded.
  • bnb.*: accepted and sharded when local shards are available, otherwise refused with the bitsandbytes ValueError.
  • like.* (AdamW8bitLike, a torch AdamW that only claims the bitsandbytes module): always refused, since it cannot step local shards.

Verification

The whole file gives 5 passed. Both bnb branches run:

UNSLOTH_FSDP2_BNB_LOCAL bnb local bnb.* like.* torch.*
1 (default) True accepted, sharded refused accepted, sharded
0 False refused refused accepted, sharded

Sabotage check: making _refuse_bnb_optimizer_cls return early fails the test.

…m / AdamW on local shards

test_bnb_optimizer_cls_and_kwargs_is_refused still expected every bitsandbytes class to be refused. Since #15008 a real bitsandbytes Adam / AdamW is kept and sharded whenever this bitsandbytes steps local shards, and refused otherwise (UNSLOTH_FSDP2_BNB_LOCAL=0). The worker now reports that, and the test asserts each arm against it; a class that only claims the bitsandbytes module is still refused.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 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-10-24T00:45:06.622611Z 0b302ce 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 0b302ce29b

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

@danielhanchen
danielhanchen merged commit 20f3b3a into main Oct 24, 2026
0 of 14 checks passed
@danielhanchen
danielhanchen deleted the ci-fsdp2-bnb-cls-contract branch October 24, 2026 00:51
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