(Phase 2)Add ModelOpt mixed FP8/NVFP4 support for image generation (#3570)

Signed-off-by: roG0d <baonudesifeizhai@gmail.com>
Signed-off-by: baonudesifeizhai <85092850+baonudesifeizhai@users.noreply.github.com>
This commit is contained in:
baonudesifeizhai authored and GitHub committed 2026-05-22 10:39:10 +08:00
1 parent 7d8816b46b
commit 076c34abfb
16 files changed
+768 -68

No files matched your search

+2 -2
View File
@@ -23,10 +23,10 @@ if TYPE_CHECKING:
)
# Pre-quantized checkpoints (modelopt FP8/FP4/MXFP8) only quantize the
# Pre-quantized checkpoints (modelopt FP8/FP4/MXFP8/mixed) only quantize the
# Thinker LM. Vision and audio encoder weights remain in BF16 with no
# corresponding scale tensors in the checkpoint.
PRE_QUANTIZED_METHODS: frozenset[str] = frozenset({"modelopt", "modelopt_fp4", "modelopt_mxfp8"})
PRE_QUANTIZED_METHODS: frozenset[str] = frozenset({"modelopt", "modelopt_fp4", "modelopt_mxfp8", "modelopt_mixed"})
def resolve_encoder_quant_config(
+12
View File
@@ -138,11 +138,19 @@ def _normalize_quant_method_alias(method: str | None) -> str | None:
_MODEL_OPT_METHODS = {
"modelopt",
"modelopt_fp4",
"modelopt_mixed",
}
_MODEL_OPT_FP8_ALGOS = {
"FP8",
"FP8_PER_CHANNEL_PER_TOKEN",
}
_MODEL_OPT_NVFP4_ALGOS = {
"NVFP4",
}
_MODEL_OPT_MIXED_ALGOS = {
"MIXED_PRECISION",
}
def _normalize_method_name(method: Any) -> str:
@@ -170,6 +178,10 @@ def _detect_modelopt_method(config: Mapping[str, Any]) -> str | None:
if quant_algo:
if quant_algo in _MODEL_OPT_FP8_ALGOS:
return "modelopt"
if quant_algo in _MODEL_OPT_NVFP4_ALGOS:
return "modelopt_fp4"
if quant_algo in _MODEL_OPT_MIXED_ALGOS:
return "modelopt_mixed"
return None
if method is not None: