Skip to content

Commit 453ac19

Browse files
committed
TL/UCP: topo aware ring algo for reduce_scatter
Replace the default ring reduce_scatter with a topo aware multi ring implementation that uses team->cuda_ring to route data along NVLink optimal paths (up to 8 parallel rings). Algorithm changes: - Ring rank, peer, and block indices are now derived from the cuda_ring topology pattern instead of flat team rank ordering. - Each ring handles its own sub block slice, with per ring GPU reductions via the executor before forwarding to the next peer. - Scratch buffer management simplified to a single mc_alloc/free per task lifetime (removed fragmentation logic). Signed-off-by: Juee Himalbhai Desai <jueehimalbha@nvidia.com>
1 parent 8806958 commit 453ac19

5 files changed

Lines changed: 407 additions & 51 deletions

File tree

src/components/tl/ucp/reduce_scatter/reduce_scatter.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include "tl_ucp.h"
88
#include "reduce_scatter.h"
99
#include "utils/ucc_coll_utils.h"
10+
#include "utils/ucc_string.h"
11+
12+
#define REDUCE_SCATTER_MAX_PATTERN_SIZE 256
1013

1114
ucc_base_coll_alg_info_t
1215
ucc_tl_ucp_reduce_scatter_algs[UCC_TL_UCP_REDUCE_SCATTER_ALG_LAST + 1] = {
@@ -20,3 +23,50 @@ ucc_base_coll_alg_info_t
2023
.desc = "recursive k-ing with arbitrary radix"},
2124
[UCC_TL_UCP_REDUCE_SCATTER_ALG_LAST] = {
2225
.id = 0, .name = NULL, .desc = NULL}};
26+
27+
char *ucc_tl_ucp_reduce_scatter_score_str_get(ucc_tl_ucp_team_t *team)
28+
{
29+
int max_size = REDUCE_SCATTER_MAX_PATTERN_SIZE;
30+
char *str = ucc_malloc(max_size * sizeof(char));
31+
ucc_tl_ucp_context_t *ctx = UCC_TL_UCP_TEAM_CTX(team);
32+
uint64_t cuda_types =
33+
ctx->ucp_memory_types &
34+
(UCC_BIT(UCC_MEMORY_TYPE_CUDA) |
35+
UCC_BIT(UCC_MEMORY_TYPE_CUDA_MANAGED));
36+
uint64_t non_cuda_types = ctx->ucp_memory_types & (~cuda_types);
37+
char *non_cuda_str;
38+
char *cuda_str;
39+
40+
if (team->cuda_ring && cuda_types) {
41+
cuda_str = ucc_malloc(max_size * sizeof(char));
42+
ucc_mtype_map_to_str(cuda_types, ",", cuda_str, max_size);
43+
if (non_cuda_types) {
44+
non_cuda_str = ucc_malloc(max_size * sizeof(char));
45+
ucc_mtype_map_to_str(non_cuda_types, ",", non_cuda_str, max_size);
46+
ucc_snprintf_safe(str, max_size,
47+
"reduce_scatter:0-4k:@%d"
48+
"#reduce_scatter:4k-inf:%s:@%d"
49+
"#reduce_scatter:4k-inf:%s:@%d",
50+
UCC_TL_UCP_REDUCE_SCATTER_ALG_KNOMIAL,
51+
cuda_str, UCC_TL_UCP_REDUCE_SCATTER_ALG_RING,
52+
non_cuda_str, UCC_TL_UCP_REDUCE_SCATTER_ALG_KNOMIAL);
53+
ucc_free(cuda_str);
54+
ucc_free(non_cuda_str);
55+
return str;
56+
}
57+
ucc_snprintf_safe(str, max_size,
58+
"reduce_scatter:0-4k:@%d"
59+
"#reduce_scatter:4k-inf:%s:@%d"
60+
"#reduce_scatter:4k-inf:@%d",
61+
UCC_TL_UCP_REDUCE_SCATTER_ALG_KNOMIAL,
62+
cuda_str, UCC_TL_UCP_REDUCE_SCATTER_ALG_RING,
63+
UCC_TL_UCP_REDUCE_SCATTER_ALG_KNOMIAL);
64+
ucc_free(cuda_str);
65+
return str;
66+
}
67+
68+
ucc_snprintf_safe(str, max_size,
69+
UCC_TL_UCP_REDUCE_SCATTER_DEFAULT_ALG_SELECT_STR,
70+
UCC_TL_UCP_REDUCE_SCATTER_ALG_KNOMIAL);
71+
return str;
72+
}

src/components/tl/ucp/reduce_scatter/reduce_scatter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ extern ucc_base_coll_alg_info_t
1919
ucc_tl_ucp_reduce_scatter_algs[UCC_TL_UCP_REDUCE_SCATTER_ALG_LAST + 1];
2020

2121
#define UCC_TL_UCP_REDUCE_SCATTER_DEFAULT_ALG_SELECT_STR \
22-
"reduce_scatter:@ring"
22+
"reduce_scatter:@%d"
23+
24+
char *ucc_tl_ucp_reduce_scatter_score_str_get(ucc_tl_ucp_team_t *team);
2325

2426
static inline int ucc_tl_ucp_reduce_scatter_alg_from_str(const char *str)
2527
{
@@ -48,4 +50,9 @@ ucc_status_t
4850
ucc_tl_ucp_reduce_scatter_ring_init(ucc_base_coll_args_t *coll_args,
4951
ucc_base_team_t * team,
5052
ucc_coll_task_t ** task_h);
53+
54+
ucc_status_t ucc_tl_ucp_reduce_scatter_ring_init_common(
55+
ucc_tl_ucp_task_t *task);
56+
57+
void ucc_tl_ucp_reduce_scatter_ring_progress(ucc_coll_task_t *coll_task);
5158
#endif

0 commit comments

Comments
 (0)