@@ -63,7 +63,11 @@ using index_t = int32_t;
6363#define MORI_COMB_BARSLEEP 15
6464#define MORI_COMB_BARSPREAD 16
6565
66- #define CUSPLIT_MAX_GPUS 8
66+ // MORI_EP_WORLD_SIZE is emitted by RenderEpSource before #include-ing this
67+ // header, so the global arrays below are sized to the exact config.
68+ #ifndef MORI_EP_WORLD_SIZE
69+ #define MORI_EP_WORLD_SIZE 8
70+ #endif
6771
6872template <typename T>
6973__device__ __forceinline__ uint32_t MoriPackTo2 (float a, float b) {
@@ -199,15 +203,15 @@ __device__ __forceinline__ gfx1250_TDM_GROUP1 TdmSplitShape(const TdmSplit128& s
199203 return TdmShape2D (32 , sp.rows );
200204}
201205
202- #define CUSPLIT_POOL_SLOTS (CUSPLIT_MAX_GPUS * 32768 )
206+ #define CUSPLIT_POOL_SLOTS (MORI_EP_WORLD_SIZE * 32768 )
203207#define CUSPLIT_MAX_BLOCKS 512
204208#define CUSPLIT_MAX_TOPK 16
205209
206210__device__ index_t _cusplit_stgIdx[CUSPLIT_POOL_SLOTS * CUSPLIT_MAX_TOPK ];
207211__device__ float _cusplit_stgWt[CUSPLIT_POOL_SLOTS * CUSPLIT_MAX_TOPK ];
208212__device__ index_t _cusplit_stgSrc[CUSPLIT_POOL_SLOTS ];
209- __device__ index_t _cusplit_blkBase[CUSPLIT_MAX_BLOCKS * CUSPLIT_MAX_GPUS ];
210- __device__ index_t _cusplit_blkCount[CUSPLIT_MAX_BLOCKS * CUSPLIT_MAX_GPUS ];
213+ __device__ index_t _cusplit_blkBase[CUSPLIT_MAX_BLOCKS * MORI_EP_WORLD_SIZE ];
214+ __device__ index_t _cusplit_blkCount[CUSPLIT_MAX_BLOCKS * MORI_EP_WORLD_SIZE ];
211215// Per-token scale rows, staged like the other meta fields so they ship to a peer as
212216// one contiguous run rather than a 224 B transfer per (token, destination) -- the
213217// size TDM is worst at. The array is at file scope, which the TU reaches before kCfg
@@ -299,7 +303,7 @@ __device__ void EpDispatch1250xBody(EpArgs args) {
299303 T* _tdmTile = reinterpret_cast <T*>(_tdmBatchSmem + (size_t )warpId * kSlabBytes );
300304 const gfx1250_TDM_GROUP1 _tdmG1 = TdmShape<T>(static_cast <int >(hiddenDim));
301305
302- constexpr int kMaxNpes = CUSPLIT_MAX_GPUS ;
306+ constexpr int kMaxNpes = kCfg . worldSize ;
303307 __shared__ index_t s_N[kMaxNpes ];
304308 __shared__ index_t s_base[kMaxNpes ];
305309 __shared__ index_t s_run[kMaxNpes ];
0 commit comments