-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Hopper MMA by warp-tile before instruction tile (#3642)
Currently we ignore the warp tile parameter when scheduling Hopper matmuls (see #3636). This PR introduces a test with different CTA, warp, and instruction tiles and modifies the Hopper scheduler to split by warp tile in addition to instruction tile. Note that the instruction tile split results in two serial loop domain so we wind up executing multiple mma instructions in each main loop. In the included example, `warp_tile` is 64, 128, 16 and the macro is `Hopper_64_8_16`. In this case, there are 128/8 = 16 instruction tiles per warp tile so the generated main loop looks like this: ```c++ #pragma unroll 3 for(nvfuser_index_t i33 = 0; i33 < i4; ++i33) { nvfuser_index_t i34; i34 = 48 + (16 * i33); nvfuser_index_t i35; i35 = (3 + i33) % 4; unsigned i36; i36 = i7 + (8192 * i35); unsigned i37; i37 = i10 + (4096 * i35); nvfuser_index_t i38; i38 = i33 % 4; unsigned i39; i39 = i13 + (4096 * i38); uint64_t i40; i40 = 4611686293305294848ULL | ((262143ULL & (uint64_t)(i39)) >> 4ULL); unsigned i41; i41 = i15 + (8192 * i38); if (((Hopper::electSync(4294967295U) && b22) && b23)) { mbarrier::arriveExpectTX(toSmem((&T8[((3LL + i33) % 4)])), 8192U); #pragma unroll for(nvfuser_index_t i31 = 0; i31 < 4; ++i31) { Hopper::cpAsyncBulkTensorTileG2S((Hopper::CpAsyncBulkTensorTileG2SIndex<2>{ ptr5, (Array<nvfuser_index_t, 2, 1>{(i6 + (64 * i31)), i34}), toSmem((&T8[((3LL + i33) % 4)])) }), (i36 + (2048 * i31))); } mbarrier::arriveExpectTX(toSmem((&T8[((3LL + i33) % 4)])), 4096U); #pragma unroll for(nvfuser_index_t i32 = 0; i32 < 2; ++i32) { Hopper::cpAsyncBulkTensorTileG2S((Hopper::CpAsyncBulkTensorTileG2SIndex<2>{ ptr8, (Array<nvfuser_index_t, 2, 1>{(i9 + (64 * i32)), i34}), toSmem((&T8[((3LL + i33) % 4)])) }), (i37 + (2048 * i32))); } } mbarrier::waitParity(toSmem((&T8[(i33 % 4)])), (uint32_t)(((i33 / 4) % 2))); #pragma unroll for(nvfuser_index_t i25 = 0; i25 < 16; ++i25) { unsigned i42; i42 = (i41 + (2048 * (i25 / 8))) + (16 * (i25 % 8)); asm volatile( "{\n" " .reg .pred p0; \n" " setp.ne.b32 p0, %6, 0;\n" " wgmma.mma_async.sync.aligned.m64n8k16.f32.f16.f16 {%0, %1, %2, %3}, %4, %5, p0, %7, %8, %9, %10;\n" "}\n" :"+f"((*reinterpret_cast<Array<float, 4, 1>*>(&T2[(4 * i25)]))[0]), "+f"((*reinterpret_cast<Array<float, 4, 1>*>(&T2[(4 * i25)]))[1]), "+f"((*reinterpret_cast<Array<float, 4, 1>*>(&T2[(4 * i25)]))[2]), "+f"((*reinterpret_cast<Array<float, 4, 1>*>(&T2[(4 * i25)]))[3]) :"l"(i40), "l"((4611686293305294848ULL | ((262143ULL & (uint64_t)(i42)) >> 4ULL))), "n"((uint32_t)(true)), "n"(1), "n"(1), "n"(1), "n"(1) ); } __syncthreads(); asm volatile("wgmma.commit_group.sync.aligned;\n"); asm volatile("wgmma.wait_group.sync.aligned %0;\n"::"n"(0LL):"memory"); } ``` Fixes #3636 --------- Co-authored-by: Ryan Spring <[email protected]>
- Loading branch information
1 parent
5bfaa0e
commit b076a55
Showing
5 changed files
with
213 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters