Repository navigation
FSDP2 QLoRA: keep 4-bit merge operands on one device in push_to_hub_merged - #14724
Merged
Merged
Conversation
push_to_hub_merged gathered with the default offload_to_cpu=True, so for merged_4bit / merged_4bit_forced the LoRA weights of packed 4-bit layers went to the CPU while the Params4bit base stayed on its GPU, and PEFT's 4-bit merge failed with a device mismatch. Use the same _fsdp2_merged_offload policy save_pretrained_merged already uses (#14165).
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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]
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
Under native FSDP2,
push_to_hub_merged(..., save_method="merged_4bit")(andmerged_4bit_forced) gathered with the defaultoffload_to_cpu=True. The LoRA weights of packed 4-bit layers went to the CPU while the Params4bit base stayed on its GPU, so PEFT's 4-bit merge on rank 0 failed with "Expected all tensors to be on the same device".#14165 fixed this for
save_pretrained_mergedwith_fsdp2_merged_offload. This passes the same callback to the Hub decorator, so both exports keep only the adapters of 4-bit layers next to their base and still send everything else to the CPU.Changes
unsloth/save.py:unsloth_generic_push_to_hub_mergedusesoffload_to_cpu = _fsdp2_merged_offload, likeunsloth_generic_save_pretrained_merged.tests/test_fsdp2_save_args.py: the offload policy test now covers both entry points,forced_merged_4bit, and checks the per-parameter decisions on a QLoRA-shaped model.Testing
tests/test_fsdp2_save_args.py: 14 passed; on main the 3push_to_hub_merged4-bit cases fail.Non-FSDP2 saves are untouched: the callback only runs when the model has FSDP2 units.