Cosmos3 FP8 ModelOpt/Diffusers remapping (#48952)
Signed-off-by: Wojciech Kutak <wkutak@nvidia.com> Signed-off-by: wkutak <wkutak@nvidia.com> Signed-off-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: Roger Wang <hey@rogerw.io>
wkutak committed
Jul 20, 2026 at 20:31 UTC
9dd62d80abad5d2ebeb0a4a60ad005a23c23d0e9
2 files changed
+43
tests/models/multimodal/test_mapping.py
+38
@@ -74,6 +74,44 @@ def test_cosmos3_new_checkpoint_weights_mapper():
74
)
75
76
77
+def test_cosmos3_modelopt_quantizer_weights_mapper():
78
+ """ModelOpt/Diffusers FP8 checkpoints ship native fake-quant buffers
79
+ (``*_quantizer._amax`` / ``._scale``) alongside the vLLM-consumable
80
+ ``weight_scale`` / ``input_scale`` sidecars. vLLM must drop the former
81
+ (it has no parameter for them) while keeping the latter."""
82
+ from vllm.model_executor.models.cosmos3 import Cosmos3ForConditionalGeneration
83
+
84
+ mapper = Cosmos3ForConditionalGeneration.hf_to_vllm_mapper
85
+
86
+ # Native ModelOpt quantizer buffers are dropped.
87
+ assert (
88
+ mapper.apply_list(
89
+ [
90
+ "layers.0.self_attn.to_q.input_quantizer._amax",
91
+ "layers.0.self_attn.to_q.weight_quantizer._amax",
92
+ "layers.0.self_attn.to_q.weight_quantizer._scale",
93
+ "layers.0.mlp.down_proj.output_quantizer._amax",
94
+ ]
95
+ )
96
+ == []
97
+ )
98
+
99
+ # The FP8 scale sidecars vLLM actually consumes are kept and remapped.
100
+ assert mapper.apply_list(
101
+ [
102
+ "layers.0.self_attn.to_q.weight",
103
+ "layers.0.self_attn.to_q.weight_scale",
104
+ "layers.0.self_attn.to_q.input_scale",
105
+ "layers.0.mlp.down_proj.input_scale",
106
+ ]
107
+ ) == [
108
+ "language_model.model.layers.0.self_attn.q_proj.weight",
109
+ "language_model.model.layers.0.self_attn.q_proj.weight_scale",
110
+ "language_model.model.layers.0.self_attn.q_proj.input_scale",
111
+ "language_model.model.layers.0.mlp.down_proj.input_scale",
112
+ ]
113
+
114
+
115
def test_cosmos3_edge_checkpoint_weights_mapper():
116
from vllm.model_executor.models.cosmos3_edge import (
117
Cosmos3EdgeForConditionalGeneration,
vllm/model_executor/models/cosmos3.py
+5
@@ -37,6 +37,11 @@ class Cosmos3ForConditionalGeneration(Qwen3VLForConditionalGeneration):
37
".to_out.": ".o_proj.",
38
".norm_q.": ".q_norm.",
39
".norm_k.": ".k_norm.",
40
+ # ModelOpt-native dialect (diffusers/transformers read these; vLLM reads
41
+ # weight_scale/input_scale instead), drop so AutoWeightsLoader passes
42
+ ".input_quantizer.": None,
43
+ ".weight_quantizer.": None,
44
+ ".output_quantizer.": None,
45
},
46
orig_to_new_prefix={
47
"proj_in.": None,