File tree Expand file tree Collapse file tree
vllm/models/deepseek_v4/nvidia Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from vllm .models .deepseek_v4 .nvidia .dspark import DSparkDeepseekV4ForCausalLM
1313from vllm .models .deepseek_v4 .nvidia .model import (
1414 DeepseekV4ForCausalLM ,
15+ DeepseekV4Model ,
1516 DeepseekV4MegaMoEExperts ,
1617 DeepseekV4MoE ,
1718 make_deepseek_v4_expert_params_mapping ,
2627)
2728
2829
30+ def test_deepseek_v4_pp_intermediate_tensors_include_input_ids ():
31+ model = DeepseekV4Model .__new__ (DeepseekV4Model )
32+ model .hc_mult = 4
33+ model .config = SimpleNamespace (hidden_size = 16 )
34+
35+ tensors = model .make_empty_intermediate_tensors (
36+ batch_size = 8 ,
37+ dtype = torch .bfloat16 ,
38+ device = torch .device ("cpu" ),
39+ )
40+
41+ assert tensors ["hidden_states" ].shape == (8 , 4 , 16 )
42+ assert tensors ["input_ids" ].shape == (8 ,)
43+ assert tensors ["input_ids" ].dtype == torch .int64
44+
45+
2946def test_deepseek_v4_mega_moe_expert_mapping ():
3047 mapping = make_deepseek_v4_expert_params_mapping (2 )
3148
Original file line number Diff line number Diff line change @@ -1386,24 +1386,31 @@ def make_empty_intermediate_tensors(
13861386 dtype = dtype ,
13871387 device = device ,
13881388 ),
1389+ "input_ids" : torch .zeros (
1390+ batch_size ,
1391+ dtype = torch .int64 ,
1392+ device = device ,
1393+ ),
13891394 }
13901395 )
13911396
13921397 def forward (
13931398 self ,
1394- input_ids : torch .Tensor ,
1399+ input_ids : torch .Tensor | None ,
13951400 positions : torch .Tensor ,
13961401 intermediate_tensors : IntermediateTensors | None ,
13971402 inputs_embeds : torch .Tensor | None = None ,
13981403 ) -> torch .Tensor | IntermediateTensors :
13991404 if get_pp_group ().is_first_rank :
1405+ assert input_ids is not None
14001406 if inputs_embeds is not None :
14011407 hidden_states = inputs_embeds
14021408 else :
14031409 hidden_states = self .embed_input_ids (input_ids )
14041410 else :
14051411 assert intermediate_tensors is not None
14061412 hidden_states = intermediate_tensors ["hidden_states" ]
1413+ input_ids = intermediate_tensors ["input_ids" ]
14071414
14081415 if self .use_mega_moe :
14091416 input_ids = input_ids .to (torch .int64 )
@@ -1457,6 +1464,7 @@ def forward(
14571464 return IntermediateTensors (
14581465 {
14591466 "hidden_states" : hidden_states ,
1467+ "input_ids" : input_ids ,
14601468 ** self .pack_local_aux_hidden_states (aux_hidden_states ),
14611469 }
14621470 )
You can’t perform that action at this time.
0 commit comments