@@ -171,10 +171,7 @@ def test_aiu_promotion_dtypes(dtype):
171171 assert "aiu_load" in compiled .asm ["ttir" ]
172172 _assert_no_tle_residue (compiled )
173173 if dtype == "fp32" :
174- aiu_instructions = [
175- line for line in compiled .asm ["llir" ].splitlines ()
176- if "ppu.cp.async.aiu" in line
177- ]
174+ aiu_instructions = [line for line in compiled .asm ["llir" ].splitlines () if "ppu.cp.async.aiu" in line ]
178175 assert aiu_instructions
179176 assert all (".b16" in line for line in aiu_instructions )
180177 assert all (".b8" not in line for line in aiu_instructions )
@@ -196,9 +193,7 @@ def test_int8_aiu_load_device_correctness():
196193 expected = torch .arange (32 * 32 , device = "cuda" , dtype = torch .int32 )
197194 expected = expected .remainder (127 ).to (torch .int8 ).reshape (32 , 32 )
198195 actual = torch .empty_like (expected )
199- _typed_aiu_load [(1 ,)](
200- expected , actual , 32 , 32 , 32 , 32 , num_warps = 4 , num_stages = 1
201- )
196+ _typed_aiu_load [(1 , )](expected , actual , 32 , 32 , 32 , 32 , num_warps = 4 , num_stages = 1 )
202197 torch .cuda .synchronize ()
203198 torch .testing .assert_close (actual .cpu (), expected .cpu (), rtol = 0 , atol = 0 )
204199
@@ -302,12 +297,10 @@ def _int8_gemm_aiu_kernel(
302297):
303298 pid_m = tl .program_id (0 )
304299 pid_n = tl .program_id (1 )
305- a_bp = tl .make_block_ptr (a_ptr , shape = (M , K ), strides = (K , 1 ),
306- offsets = (pid_m * BLOCK_M , 0 ),
300+ a_bp = tl .make_block_ptr (a_ptr , shape = (M , K ), strides = (K , 1 ), offsets = (pid_m * BLOCK_M , 0 ),
307301 block_shape = (BLOCK_M , BLOCK_K ), order = (1 , 0 ))
308302 # b_ptr is physically contiguous [N, K], logically column-major [K, N].
309- b_bp = tl .make_block_ptr (b_ptr , shape = (K , N ), strides = (1 , K ),
310- offsets = (0 , pid_n * BLOCK_N ),
303+ b_bp = tl .make_block_ptr (b_ptr , shape = (K , N ), strides = (1 , K ), offsets = (0 , pid_n * BLOCK_N ),
311304 block_shape = (BLOCK_K , BLOCK_N ), order = (0 , 1 ))
312305 acc = tl .zeros ((BLOCK_M , BLOCK_N ), dtype = tl .int32 )
313306 for _ in range (0 , K , BLOCK_K ):
@@ -318,8 +311,7 @@ def _int8_gemm_aiu_kernel(
318311 b_bp = tl .advance (b_bp , (BLOCK_K , 0 ))
319312 offs_m = pid_m * BLOCK_M + tl .arange (0 , BLOCK_M )
320313 offs_n = pid_n * BLOCK_N + tl .arange (0 , BLOCK_N )
321- tl .store (c_ptr + N * offs_m [:, None ] + offs_n [None , :], acc ,
322- mask = (offs_m [:, None ] < M ) & (offs_n [None , :] < N ))
314+ tl .store (c_ptr + N * offs_m [:, None ] + offs_n [None , :], acc , mask = (offs_m [:, None ] < M ) & (offs_n [None , :] < N ))
323315
324316
325317@_skip_no_sdk
@@ -345,9 +337,7 @@ def test_int8_gemm_uses_v1_b8_aiu_load_and_int8_mma():
345337@pytest .mark .skipif (not torch .cuda .is_available (), reason = "PPU device not available" )
346338@pytest .mark .parametrize (
347339 "m,n,k,bm,bn,bk,num_warps" ,
348- [(16 , 16 , 32 , 16 , 16 , 32 , 1 ),
349- (16 , 32 , 64 , 16 , 32 , 64 , 1 ),
350- (64 , 64 , 64 , 64 , 64 , 64 , 4 ),
340+ [(16 , 16 , 32 , 16 , 16 , 32 , 1 ), (16 , 32 , 64 , 16 , 32 , 64 , 1 ), (64 , 64 , 64 , 64 , 64 , 64 , 4 ),
351341 (128 , 128 , 128 , 64 , 64 , 64 , 4 )],
352342)
353343def test_int8_gemm_aiu_device_correctness (m , n , k , bm , bn , bk , num_warps ):
@@ -356,8 +346,7 @@ def test_int8_gemm_aiu_device_correctness(m, n, k, bm, bn, bk, num_warps):
356346 b = torch .randint (- 8 , 9 , (n , k ), device = "cuda" , dtype = torch .int8 )
357347 actual = torch .empty ((m , n ), device = "cuda" , dtype = torch .int32 )
358348 grid = (triton .cdiv (m , bm ), triton .cdiv (n , bn ))
359- _int8_gemm_aiu_kernel [grid ](a , b , actual , m , n , k , bm , bn , bk ,
360- num_warps = num_warps , num_stages = 1 )
349+ _int8_gemm_aiu_kernel [grid ](a , b , actual , m , n , k , bm , bn , bk , num_warps = num_warps , num_stages = 1 )
361350 torch .cuda .synchronize ()
362351 expected = a .cpu ().to (torch .int32 ) @ b .cpu ().to (torch .int32 ).T
363352 torch .testing .assert_close (actual .cpu (), expected , rtol = 0 , atol = 0 )
@@ -445,8 +434,7 @@ def kernel(a_ptr, c_ptr, M: tl.constexpr, K: tl.constexpr, BLOCK_M: tl.constexpr
445434 mask = (offs_m [:, None ] < M ) & (offs_k [None , :] < K ))
446435
447436 compiled = _compile (kernel , {"a_ptr" : "*fp16" , "c_ptr" : "*fp16" },
448- {"M" : 512 , "K" : 512 , "BLOCK_M" : 64 , "BLOCK_K" : 64 },
449- options = {"num_stages" : num_stages })
437+ {"M" : 512 , "K" : 512 , "BLOCK_M" : 64 , "BLOCK_K" : 64 }, options = {"num_stages" : num_stages })
450438 _assert_stages_exist (compiled )
451439 assert "aiu_load" in compiled .asm ["ttir" ]
452440 _assert_no_tle_residue (compiled )
@@ -467,12 +455,10 @@ def kernel(a_ptr, c_ptr, M: tl.constexpr, K: tl.constexpr, BLOCK_M: tl.constexpr
467455 a_bp = tl .advance (a_bp , (0 , BLOCK_K ))
468456 offs_m = pid * BLOCK_M + tl .arange (0 , BLOCK_M )
469457 offs_k = tl .arange (0 , BLOCK_K )
470- tl .store (c_ptr + K * offs_m [:, None ] + offs_k [None , :], acc ,
471- mask = (offs_m [:, None ] < M ) & (offs_k [None , :] < K ))
458+ tl .store (c_ptr + K * offs_m [:, None ] + offs_k [None , :], acc , mask = (offs_m [:, None ] < M ) & (offs_k [None , :] < K ))
472459
473460 compiled = _compile_through_llir (kernel , {"a_ptr" : "*i8" , "c_ptr" : "*i32" },
474- {"M" : 512 , "K" : 512 , "BLOCK_M" : 64 , "BLOCK_K" : 64 },
475- options = {"num_stages" : 2 })
461+ {"M" : 512 , "K" : 512 , "BLOCK_M" : 64 , "BLOCK_K" : 64 }, options = {"num_stages" : 2 })
476462 _assert_stages_exist (compiled )
477463 assert "aiu_load" in compiled .asm ["ttir" ]
478464 _assert_no_tle_residue (compiled )
0 commit comments