@@ -112,6 +112,48 @@ def test_sigmoid_gate_without_optional_correction_bias_has_no_bias_parameter():
112112 assert [name for name , _ in gate .named_parameters ()] == ["weight" ]
113113
114114
115+ def test_dots1_routing_normalization_uses_pinned_llama_floor ():
116+ config = make_config (
117+ hidden_size = 1 ,
118+ num_local_experts = 2 ,
119+ num_experts_per_tok = 2 ,
120+ scoring_func = "sigmoid" ,
121+ use_expert_bias = False ,
122+ norm_topk_prob = True ,
123+ routing_weight_normalization_floor = 6.103515625e-5 ,
124+ )
125+ gate = DeepSeekMoEGate (config )
126+ gate .weight .const_value = ir .tensor (np .ones ((2 , 1 ), dtype = np .float32 ))
127+
128+ hidden = ir .Value (
129+ name = "hidden_states" ,
130+ shape = ir .Shape ([1 , 1 , 1 ]),
131+ type = ir .TensorType (ir .DataType .FLOAT ),
132+ )
133+ graph = ir .Graph (
134+ inputs = [hidden ],
135+ outputs = [],
136+ nodes = [],
137+ name = "dots1_routing_floor" ,
138+ opset_imports = {"" : OPSET_VERSION },
139+ )
140+ builder = GraphBuilder (graph )
141+ routing_weights , _ = gate (builder .op , hidden )
142+ routing_weights .name = "routing_weights"
143+ graph .outputs .append (routing_weights )
144+
145+ session = ort .InferenceSession (
146+ ir .to_proto (ir .Model (graph , ir_version = 11 )).SerializeToString (),
147+ providers = ["CPUExecutionProvider" ],
148+ )
149+ actual = session .run (None , {"hidden_states" : np .array ([[[- 11.0 ]]], dtype = np .float32 )})[0 ]
150+ score = 1.0 / (1.0 + np .exp (11.0 ))
151+ expected = np .full ((1 , 1 , 2 ), score / 6.103515625e-5 , dtype = np .float32 )
152+
153+ np .testing .assert_allclose (actual , expected , rtol = 2e-3 , atol = 1e-8 )
154+ assert actual .sum () < 1.0
155+
156+
115157@pytest .mark .parametrize (
116158 ("scoring_func" , "expects_bias" ),
117159 [("softmax" , False ), ("sigmoid" , True )],
0 commit comments