diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-06 07:50:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-06 07:50:38 +0000 |
commit | 8b6848c6dbee95f055b98b33804b12bd188ac625 (patch) | |
tree | 14edd2720a22827674a7a1e090338fc1cf148237 /extensions-builtin/Lora | |
parent | a4ee64050a15263c73884ed7797c5332c9f559c1 (diff) | |
parent | f8f38c7c28e48f9f79225c969e3e82b1adcfb910 (diff) | |
download | stable-diffusion-webui-gfx803-8b6848c6dbee95f055b98b33804b12bd188ac625.tar.gz stable-diffusion-webui-gfx803-8b6848c6dbee95f055b98b33804b12bd188ac625.tar.bz2 stable-diffusion-webui-gfx803-8b6848c6dbee95f055b98b33804b12bd188ac625.zip |
Merge pull request #14546 from AUTOMATIC1111/fix-oft-dtype
Fix dtype casting in OFT module
Diffstat (limited to 'extensions-builtin/Lora')
-rw-r--r-- | extensions-builtin/Lora/network_oft.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/extensions-builtin/Lora/network_oft.py b/extensions-builtin/Lora/network_oft.py index fa647020..342fcd0d 100644 --- a/extensions-builtin/Lora/network_oft.py +++ b/extensions-builtin/Lora/network_oft.py @@ -56,7 +56,7 @@ class NetworkModuleOFT(network.NetworkModule): self.block_size, self.num_blocks = factorization(self.out_dim, self.dim) def calc_updown(self, orig_weight): - oft_blocks = self.oft_blocks.to(orig_weight.device, dtype=orig_weight.dtype) + oft_blocks = self.oft_blocks.to(orig_weight.device) eye = torch.eye(self.block_size, device=self.oft_blocks.device) if self.is_kohya: @@ -66,7 +66,7 @@ class NetworkModuleOFT(network.NetworkModule): block_Q = block_Q * ((new_norm_Q + 1e-8) / (norm_Q + 1e-8)) oft_blocks = torch.matmul(eye + block_Q, (eye - block_Q).float().inverse()) - R = oft_blocks.to(orig_weight.device, dtype=orig_weight.dtype) + R = oft_blocks.to(orig_weight.device) # This errors out for MultiheadAttention, might need to be handled up-stream merged_weight = rearrange(orig_weight, '(k n) ... -> k n ...', k=self.num_blocks, n=self.block_size) @@ -77,6 +77,6 @@ class NetworkModuleOFT(network.NetworkModule): ) merged_weight = rearrange(merged_weight, 'k m ... -> (k m) ...') - updown = merged_weight.to(orig_weight.device, dtype=orig_weight.dtype) - orig_weight + updown = merged_weight.to(orig_weight.device) - orig_weight.to(merged_weight.dtype) output_shape = orig_weight.shape return self.finalize_updown(updown, orig_weight, output_shape) |