diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-23 19:34:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 19:34:24 +0000 |
commit | 358e9e2847efae0cd45107edbf050925a1a068df (patch) | |
tree | 1821fdafa5967ddcef2f182f6003d92ab807caa8 /extensions-builtin | |
parent | c17f7ee694a42ad09b570755a1562e9ab5ba2b73 (diff) | |
parent | fd383140cf405100f3c619f106472273a7545beb (diff) | |
download | stable-diffusion-webui-gfx803-358e9e2847efae0cd45107edbf050925a1a068df.tar.gz stable-diffusion-webui-gfx803-358e9e2847efae0cd45107edbf050925a1a068df.tar.bz2 stable-diffusion-webui-gfx803-358e9e2847efae0cd45107edbf050925a1a068df.zip |
Merge pull request #14726 from v0xie/fix-oft-device
Fix kohya-ss OFT network wrong device for eye and constraint
Diffstat (limited to 'extensions-builtin')
-rw-r--r-- | extensions-builtin/Lora/network_oft.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/extensions-builtin/Lora/network_oft.py b/extensions-builtin/Lora/network_oft.py index 342fcd0d..d1c46a4b 100644 --- a/extensions-builtin/Lora/network_oft.py +++ b/extensions-builtin/Lora/network_oft.py @@ -57,12 +57,12 @@ class NetworkModuleOFT(network.NetworkModule): def calc_updown(self, orig_weight): oft_blocks = self.oft_blocks.to(orig_weight.device) - eye = torch.eye(self.block_size, device=self.oft_blocks.device) + eye = torch.eye(self.block_size, device=oft_blocks.device) if self.is_kohya: block_Q = oft_blocks - oft_blocks.transpose(1, 2) # ensure skew-symmetric orthogonal matrix norm_Q = torch.norm(block_Q.flatten()) - new_norm_Q = torch.clamp(norm_Q, max=self.constraint) + new_norm_Q = torch.clamp(norm_Q, max=self.constraint.to(oft_blocks.device)) 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()) |