Skip to content

Commit bb905ec

Browse files
dboydafacebook-github-bot
authored andcommitted
S651852 [ctran][tests] Cover non-zero designated CTA in localReduce unaligned-tail tests
Summary: The next diff in this stack changes `localReduceVectorized` and `localReduceFallback` to use a single-designated-CTA tail (matching `copyUnroll<4, T>`'s pattern). Existing `localReduceSumUnaligned` (`fbcode/comms/ctran/algos/tests/CtranAlgoDevUT.cc:298`) only exercises the `count=1041, blockDim=640, gridDim=2` configuration, where the designated tail CTA collapses to block 0 for every supported dtype — leaving the new "tail handled by a non-zero CTA" code path untested. Adds `localReduceSumUnalignedNonZeroDesignatedCta` covering counts `{10241, 20481, 30721, 40961}` with `gridDim=4`. For T=float (sizeofT=4), `numPerBlock = blockDim * (16/sizeof(T)) * 4 = 640 * 16 = 10240`, so: - count=10241 -> tail=1, designated=1 - count=20481 -> tail=1, designated=2 - count=30721 -> tail=1, designated=3 - count=40961 -> tail=1, designated=0 (wrap) For other dtypes the designated index shifts proportionally with `numPerBlock`; in every combination the tail is non-empty and at least one count puts it on a non-zero block. The test passes on the current (pre-fix) code as well — both writer-tail variants must produce correct reductions in single-call usage; this only tightens regression coverage so the next diff's tail rewrite cannot silently drop bytes when the tail belongs to a CTA other than block 0. Differential Revision: D103456130
1 parent 65eaafb commit bb905ec

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

comms/ctran/algos/tests/CtranAlgoDevUT.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,40 @@ TYPED_TEST(CtranAlgoDevTypedTest, localReduceSumUnaligned) {
309309
}
310310
}
311311

312+
// Exercises localReduce at counts where the tail's "designated CTA"
313+
// (under copyUnroll-style per-block ownership = `(limitCount/numPerBlock)
314+
// % nGroups`) is NOT block 0. Existing localReduceSumUnaligned uses
315+
// count=1041 with blockDim=640 and gridDim=2, where for every supported
316+
// dtype the designated CTA collapses to 0; this test covers the case
317+
// where the tail is owned by a non-zero block.
318+
TYPED_TEST(CtranAlgoDevTypedTest, localReduceSumUnalignedNonZeroDesignatedCta) {
319+
std::vector<size_t> testnSrcs{2, 8};
320+
std::vector<size_t> testnDsts{1, 2};
321+
constexpr uint numThreadBlocks = 4;
322+
// For T=float (sizeofT=4), blockDim=640: numPerBlock = 640 * (16/4) * 4
323+
// = 10240. count=10241 => limitCount=10240, tail=1, designated=1.
324+
// count=20481 => designated=2. count=30721 => designated=3. count=40961
325+
// => designated=0 (wrap). For other dtypes the designated index shifts
326+
// proportionally; in every case the tail is non-empty and at least one
327+
// count puts it on a non-zero block.
328+
std::vector<size_t> testCounts{10241, 20481, 30721, 40961};
329+
330+
for (auto nsrcs : testnSrcs) {
331+
for (auto ndsts : testnDsts) {
332+
for (auto count : testCounts) {
333+
localReduceTest<TypeParam>(
334+
nsrcs,
335+
ndsts,
336+
count,
337+
commSum,
338+
/*nranks=*/1,
339+
/*subsetThreadBlocks=*/false,
340+
numThreadBlocks);
341+
}
342+
}
343+
}
344+
}
345+
312346
TYPED_TEST(CtranAlgoDevTypedTest, localReduceProd) {
313347
// test reduction kernel with 2 or 8 srcs, and 1 or 2 dsts, which are common
314348
// cases for inter-node and intra-node collectives.

0 commit comments

Comments
 (0)