prometheusAIR commited on
Commit
31e237d
·
verified ·
1 Parent(s): 66412be

Fix NVFP4 config-building crash (dict-vs-list format assumption) in build_quant_cfg

Browse files
Files changed (1) hide show
  1. serve_cosmos3_i2v4step_diffusers.py +11 -8
serve_cosmos3_i2v4step_diffusers.py CHANGED
@@ -100,15 +100,18 @@ def build_quant_cfg(fmt: str) -> dict:
100
  }
101
  if fmt == "nvfp4":
102
  import copy
 
 
 
 
 
 
 
 
 
 
103
  base = getattr(mtq, "W4A16_NVFP4_CFG", None) or mtq.NVFP4_DEFAULT_CFG
104
- cfg = copy.deepcopy(base)
105
- cfg.setdefault("quant_cfg", {})
106
- cfg["quant_cfg"]["*input_quantizer"] = {"enable": False}
107
- cfg["quant_cfg"]["*output_quantizer"] = {"enable": False}
108
- cfg["quant_cfg"]["*softmax_quantizer"] = {"enable": False}
109
- for s in SPARE_SUBSTRINGS:
110
- cfg["quant_cfg"][f"*{s}*weight_quantizer"] = {"enable": False}
111
- return cfg
112
  raise ValueError(f"Unknown format: {fmt!r}")
113
 
114
 
 
100
  }
101
  if fmt == "nvfp4":
102
  import copy
103
+ # Return the base preset UNMODIFIED -- on this installed modelopt version,
104
+ # W4A16_NVFP4_CFG's quant_cfg is a LIST (newer format), not the dict this
105
+ # function used to assume (confirmed empirically: "TypeError: list indices
106
+ # must be integers or slices, not str" trying dict-style key assignment
107
+ # here). enforce_weight_only_and_spare() below disables activations/spares
108
+ # on the model's actual inserted quantizer modules AFTER mtq.quantize(),
109
+ # which is config-form agnostic -- no need to pre-bake into the config dict.
110
+ # load_cosmos3_modelopt.py's loader re-applies the same disabling on every
111
+ # restore anyway (modelopt_state replays the config, not our imperative
112
+ # .disable() calls), so skipping the pre-bake here loses nothing.
113
  base = getattr(mtq, "W4A16_NVFP4_CFG", None) or mtq.NVFP4_DEFAULT_CFG
114
+ return copy.deepcopy(base)
 
 
 
 
 
 
 
115
  raise ValueError(f"Unknown format: {fmt!r}")
116
 
117