Use comfy.quant_ops NVFP4 layout and exact MM3_NVFP4=1 gate
- Import TensorCoreNVFP4Layout from comfy.quant_ops so ComfyUI's quantize override and Params contract apply; comfy_kitchen stays lazy for the dequantize helpers. - Gate the conversion on the exact documented value MM3_NVFP4=1 in both load paths.
This commit is contained in:
parent
5ae70eec8a
commit
287299e0e7
|
|
@ -2267,7 +2267,7 @@ def load_diffusion_model_state_dict(sd, model_options={}, metadata=None, disable
|
|||
parameters = comfy.utils.calculate_parameters(sd)
|
||||
weight_dtype = comfy.utils.weight_dtype(sd)
|
||||
|
||||
if os.environ.get("MM3_NVFP4") and metadata is not None and metadata.get("comfy_model") == "minimax_music3_dit":
|
||||
if os.environ.get("MM3_NVFP4") == "1" and metadata is not None and metadata.get("comfy_model") == "minimax_music3_dit":
|
||||
comfy.text_encoders.minimax_music._to_nvfp4(sd)
|
||||
|
||||
load_device = model_options.get("load_device", model_management.get_torch_device())
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ def _to_nvfp4(sd):
|
|||
bytes, so the AR model's resident set fits VRAM and aimdo stops paging.
|
||||
"""
|
||||
import comfy_kitchen as ck
|
||||
from comfy_kitchen.tensor.nvfp4 import TensorCoreNVFP4Layout
|
||||
from comfy.quant_ops import TensorCoreNVFP4Layout
|
||||
|
||||
dtype_code = ck.DTYPE_TO_CODE[torch.float32]
|
||||
for key in list(sd):
|
||||
|
|
@ -132,7 +132,7 @@ class MiniMaxMusic3TEModel(MiniMaxMusic3AR):
|
|||
return hidden.unsqueeze(0), None, {}
|
||||
|
||||
def load_state_dict(self, state_dict, strict=True, assign=False):
|
||||
if os.environ.get("MM3_NVFP4"):
|
||||
if os.environ.get("MM3_NVFP4") == "1":
|
||||
_to_nvfp4(state_dict)
|
||||
if self.model.pruned_embedding is None:
|
||||
self.model.pruned_embedding = "model.embed_tokens_prefill.weight" in state_dict
|
||||
|
|
|
|||
Loading…
Reference in New Issue