MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / load_fp8_weight

Method load_fp8_weight

tools/convert/quant/quant.py:59–79  ·  view source on GitHub ↗
(self, w, comfyui_mode=False)

Source from the content-addressed store, hash-verified

57
58 if not comfyui_mode:
59 scales = scales.view(org_w_shape[0], -1)
60 w_q = w_q.reshape(org_w_shape)
61
62 return w_q, scales, self.extra
63
64
65@CONVERT_WEIGHT_REGISTER("int8-convrot")
66class QuantWeightINT8ConvRot(QuantTemplate):
67 def __init__(self, weight):
68 super().__init__(weight)
69 self.weight_quant_func = self.load_int8_convrot_weight
70
71 @torch.no_grad()
72 def load_int8_convrot_weight(self, w, comfyui_mode=False):
73 if TensorWiseINT8Layout is None:
74 raise ImportError("INT8 ConvRot conversion requires comfy-kitchen. Install it with `pip install comfy-kitchen`.")
75 if comfyui_mode:
76 raise ValueError("int8-convrot is a LightX2V checkpoint format and does not support --comfyui_mode")
77 convrot_groupsize = next((groupsize for groupsize in CONVROT_GROUPSIZES if w.shape[1] % groupsize == 0), None)
78 if convrot_groupsize is None:
79 raise ValueError(f"INT8 ConvRot requires in_features divisible by one of {CONVROT_GROUPSIZES}, got weight shape {tuple(w.shape)}")
80
81 w_q, params = TensorWiseINT8Layout.quantize(
82 w.contiguous(),

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected