fix: SDXL DoRA LoRA fails with enable_partial_loading=true#9063
Open
Pfannkuchensack wants to merge 6 commits intomainfrom
Open
fix: SDXL DoRA LoRA fails with enable_partial_loading=true#9063Pfannkuchensack wants to merge 6 commits intomainfrom
Pfannkuchensack wants to merge 6 commits intomainfrom
Conversation
cast_to_device returns plain torch.Tensor instead of torch.nn.Parameter, causing _aggregate_patch_parameters to replace valid weights with meta device dummies, falsely triggering DoRA's quantization guard. Fixes #8624
Collaborator
Author
Collaborator
Otherwise it's good - ping me if you write this test or decide it's too difficult, @Pfannkuchensack. |
…ocast Adds targeted coverage for the bug fixed in a0a8721 (#8624, PR #9063): - test_aggregate_patch_parameters_preserves_plain_tensor_with_dora: CPU-only unit test that feeds a plain torch.Tensor (as handed in by _cast_weight_bias_for_input) into _aggregate_patch_parameters with a DoRA patch. Pre-fix, the tensor was replaced by a meta-device dummy, tripping DoRA's quantization guard. - "single_dora" variant in the patch_under_test fixture: exercises the full CUDA/MPS autocast hot path via test_linear_sidecar_patches_with_autocast_from_cpu_to_device.
JPPhoto
approved these changes
Apr 22, 2026
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
cast_to_devicereturns a plaintorch.Tensorinstead oftorch.nn.Parameterwhen moving parameters between devices. This causes_aggregate_patch_parametersto replace valid weights withmetadevice dummies, falsely triggering DoRA's quantization guard.Added a check for plain
torch.Tensorin_aggregate_patch_parametersso that parameters cast to a different device are recognized as valid non-quantized weights.Fixes #8624
Related Issues / Discussions
enable_partial_loading=trueQA Instructions
enable_partial_loading=true"base model quantization format (likely bitsandbytes) is not compatible with DoRA patches"errorMerge Plan
Single-file change, safe to merge anytime.
Checklist
What's Newcopy (if doing a release after this PR)