Make loras work on nvfp4 models. (#11837)

The initial applying is a bit slow but will probably be sped up in the
future.
This commit is contained in:
comfyanonymous
2026-01-12 19:33:54 -08:00
committed by GitHub
parent ecaeeb990d
commit b3c0e4de57
4 changed files with 150 additions and 4 deletions

View File

@@ -699,7 +699,7 @@ def mixed_precision_ops(quant_config={}, compute_dtype=torch.bfloat16, full_prec
def set_weight(self, weight, inplace_update=False, seed=None, return_weight=False, **kwargs):
if getattr(self, 'layout_type', None) is not None:
# dtype is now implicit in the layout class
weight = QuantizedTensor.from_float(weight, self.layout_type, scale="recalculate", stochastic_rounding=seed, inplace_ops=True)
weight = QuantizedTensor.from_float(weight, self.layout_type, scale="recalculate", stochastic_rounding=seed, inplace_ops=True).to(self.weight.dtype)
else:
weight = weight.to(self.weight.dtype)
if return_weight: