File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
fastdeploy/model_executor/layers/moe Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -775,9 +775,21 @@ async def put(
775775 routing_indices : np .ndarray ,
776776 ) -> None :
777777 """Put the routing indices into store"""
778- # TODO(gongshaotian) covert ./store_dir/routing_key/layer_id.pdtensor to ./store_dir/routing_key.pt
778+ # TODO(gongshaotian) covert ./store_dir/routing_key/layer_id.pdtensor to ./store_dir/routing_key.pdtensor
779779 time_before_put = time .perf_counter ()
780- file_path = os .path .join (self .local_store_dir , f"{ routing_key } .pdtensor" )
780+
781+ if len (routing_indices .shape ) == 2 :
782+ re_layer_id , re_rollout_id = routing_key [::- 1 ].split ("_" , 1 )
783+ rollout_id = re_rollout_id [::- 1 ]
784+ layer_id = re_layer_id [::- 1 ]
785+ request_path = os .path .join (self .local_store_dir , rollout_id )
786+ file_path = os .path .join (request_path , f"layer_{ layer_id } .pdtensor" )
787+ elif len (routing_indices .shape ) == 3 :
788+ request_path = os .path .join (self .local_store_dir , routing_key )
789+ file_path = os .path .join (request_path , f"{ routing_key } .pdtensor" )
790+ else :
791+ raise ValueError (f"Invalid routing indices shape: { routing_indices .shape } " )
792+
781793 paddle .save (routing_indices , file_path )
782794 logger .info (f"[R3] The routing key { routing_key } put cost is { time .perf_counter ()- time_before_put } s" )
783795
You can’t perform that action at this time.
0 commit comments