MCPcopy Create free account
hub / github.com/KohakuBlueleaf/LyCORIS / load_weight_prehook

Method load_weight_prehook

lycoris/modules/full.py:134–148  ·  view source on GitHub ↗
(
        self,
        state_dict,
        prefix,
        local_metadata,
        strict,
        missing_keys,
        unexpected_keys,
        error_msgs,
    )

Source from the content-addressed store, hash-verified

132 sd["diff_b"] = self.bias.data.cpu() - self.org_bias[0]
133 return sd
134
135 def load_weight_prehook(
136 self,
137 state_dict,
138 prefix,
139 local_metadata,
140 strict,
141 missing_keys,
142 unexpected_keys,
143 error_msgs,
144 ):
145 diff_weight = state_dict.pop(f"{prefix}diff")
146 state_dict[f"{prefix}weight"] = diff_weight + self.weight.data.to(diff_weight)
147 if f"{prefix}diff_b" in state_dict:
148 diff_bias = state_dict.pop(f"{prefix}diff_b")
149 state_dict[f"{prefix}bias"] = diff_bias + self.bias.data.to(diff_bias)
150
151 def _org_bias_tensor(self, device=None, dtype=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected