@@ -89,6 +89,9 @@ pub struct VllmPDRouter {
8989 intra_node_data_parallel_size : usize ,
9090 /// Round-robin counter for prefill DP rank selection
9191 prefill_dp_round_robin : Arc < AtomicUsize > ,
92+ /// Total (cross-pod) MoRI-IO DP world size for Wide-EP (e.g. 16 for 2P2D DP=16).
93+ /// 0 -> fall back to intra_node_data_parallel_size.
94+ moriio_dp_size : usize ,
9295 /// KV connector type
9396 kv_connector : KvConnector ,
9497 /// Mooncake bootstrap info: prefill base_url -> MooncakePrefillInfo
@@ -234,6 +237,18 @@ impl VllmPDRouter {
234237 }
235238 }
236239
240+ /// Effective MoRI-IO DP world size: the total cross-pod DP size when configured
241+ /// (--moriio-dp-size, e.g. 16 for 2P2D DP=16), else the intra-node size. Used to
242+ /// round-robin a single per-request DP rank over the whole world and to stamp
243+ /// remote_dp_size so the MoRIIO connector's rank arithmetic matches the topology.
244+ fn effective_dp_size ( & self ) -> usize {
245+ if self . moriio_dp_size > 0 {
246+ self . moriio_dp_size
247+ } else {
248+ self . intra_node_data_parallel_size
249+ }
250+ }
251+
237252 /// Build kv_transfer_params for the prefill request.
238253 ///
239254 /// Returns an error for MoRI-IO when no transfer mode has been registered yet, so that
@@ -271,7 +286,7 @@ impl VllmPDRouter {
271286 "do_remote_prefill" : false ,
272287 "remote_engine_id" : serde_json:: Value :: Null ,
273288 "remote_block_ids" : serde_json:: Value :: Null ,
274- "remote_dp_size" : self . intra_node_data_parallel_size ,
289+ "remote_dp_size" : self . effective_dp_size ( ) ,
275290 "remote_tp_size" : remote_tp_size,
276291 "transfer_id" : transfer_id. unwrap_or( "" ) ,
277292 } ) ;
@@ -287,7 +302,7 @@ impl VllmPDRouter {
287302 "remote_engine_id" : serde_json:: Value :: Null ,
288303 "remote_block_ids" : serde_json:: Value :: Null ,
289304 "transfer_id" : transfer_id. unwrap_or( "" ) ,
290- "remote_dp_size" : self . intra_node_data_parallel_size ,
305+ "remote_dp_size" : self . effective_dp_size ( ) ,
291306 } ) )
292307 }
293308 }
@@ -345,12 +360,18 @@ impl VllmPDRouter {
345360 "remote_engine_id" : serde_json:: Value :: Null ,
346361 "remote_block_ids" : serde_json:: Value :: Null ,
347362 "transfer_id" : transfer_id. unwrap_or( "" ) ,
348- "remote_dp_size" : self . intra_node_data_parallel_size ,
363+ "remote_dp_size" : self . effective_dp_size ( ) ,
349364 "remote_tp_size" : tp_size,
350365 } ) ;
351- if self . intra_node_data_parallel_size > 1 {
366+ if self . effective_dp_size ( ) > 1 {
352367 if let Some ( rank) = prefill_dp_rank {
353368 params[ "remote_dp_rank" ] = json ! ( rank) ;
369+ // Sentinel: tell the MoRIIO connector (vllm#45043) to honor
370+ // this rank VERBATIM on both legs instead of re-hashing
371+ // blake2s(rid)%dp_size for the decode notify. Without it the
372+ // decode notify targets a different rank than the prefill was
373+ // pinned to -> "remote blocks never arrived" write expiry.
374+ params[ "remote_dp_rank_override" ] = json ! ( true ) ;
354375 }
355376 }
356377 Some ( params)
@@ -1111,13 +1132,21 @@ impl VllmPDRouter {
11111132 let transfer_id = self . generate_transfer_id ( ) ;
11121133
11131134 let ( prefill_base_http, mut prefill_dp_rank) = dp_utils:: parse_worker_url ( prefill_http) ;
1114- let ( decode_base_http, decode_dp_rank) = dp_utils:: parse_worker_url ( decode_http) ;
1135+ let ( decode_base_http, mut decode_dp_rank) = dp_utils:: parse_worker_url ( decode_http) ;
11151136
1116- if self . intra_node_data_parallel_size > 1 && prefill_dp_rank. is_none ( ) {
1137+ // Round-robin a single DP rank H over the FULL (cross-pod) DP world (effective_dp_size:
1138+ // --moriio-dp-size when set, else intra-node) so the prefill request is pinned to rank H
1139+ // and the decode kv_transfer_params carry remote_dp_rank=H (+ override).
1140+ let _eff_dp = self . effective_dp_size ( ) ;
1141+ if _eff_dp > 1 && prefill_dp_rank. is_none ( ) {
11171142 let rank = self . prefill_dp_round_robin . fetch_add ( 1 , Ordering :: Relaxed )
1118- % self . intra_node_data_parallel_size ;
1143+ % _eff_dp ;
11191144 prefill_dp_rank = Some ( rank) ;
11201145 }
1146+ // Pin decode to the SAME rank as prefill (override contract requires it).
1147+ if prefill_dp_rank. is_some ( ) {
1148+ decode_dp_rank = prefill_dp_rank;
1149+ }
11211150
11221151 // Add kv_transfer_params for KV connector support at top level
11231152 prefill_request[ "kv_transfer_params" ] = self . build_prefill_kv_transfer_params (
@@ -2134,6 +2163,7 @@ impl VllmPDRouter {
21342163 profiling_tasks : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
21352164 intra_node_data_parallel_size : ctx. router_config . intra_node_data_parallel_size ,
21362165 prefill_dp_round_robin : Arc :: new ( AtomicUsize :: new ( 0 ) ) ,
2166+ moriio_dp_size : ctx. router_config . moriio_dp_size ,
21372167 kv_connector,
21382168 mooncake_prefill_info : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
21392169 nixl_prefill_info : RwLock :: new ( HashMap :: new ( ) ) ,
@@ -2228,6 +2258,7 @@ impl VllmPDRouter {
22282258 profiling_tasks : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
22292259 intra_node_data_parallel_size : ctx. router_config . intra_node_data_parallel_size ,
22302260 prefill_dp_round_robin : Arc :: new ( AtomicUsize :: new ( 0 ) ) ,
2261+ moriio_dp_size : ctx. router_config . moriio_dp_size ,
22312262 kv_connector,
22322263 mooncake_prefill_info,
22332264 nixl_prefill_info : RwLock :: new ( HashMap :: new ( ) ) ,
0 commit comments