Skip to content

Commit 220c250

Browse files
maggiemossmeta-codesync[bot]
authored andcommitted
Remove unused type error suppressions - ads_mkl/ops
Summary: This diff was automatically generated by the Pyre per-target upgrade tool. It removes `# pyre-fixme` or `pyrefly: ignore` comments that are no longer needed because the underlying type errors have been resolved. Note that it will also aim to ensure type checking runs cleanly, and will add suppressions to existing type errors. #pyreupgrade Reviewed By: shobhitmehro Differential Revision: D114771938 fbshipit-source-id: 793b1012fc85e21b07e0632b5f2efe39d347a56a
1 parent d3e0e6f commit 220c250

6 files changed

Lines changed: 9 additions & 100 deletions

File tree

gdpa/src/activation_utils.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@
2727
E8M0_NEUTRAL_SCALE: int = 127
2828

2929

30-
# pyre-ignore[56]
3130
@dsl_user_op
3231
def pack_4xu8_to_u32(
33-
# pyre-ignore[11]
3432
b0: Uint8,
3533
b1: Uint8,
3634
b2: Uint8,
3735
b3: Uint8,
3836
*,
3937
loc: object | None = None,
4038
ip: object | None = None,
41-
# pyre-ignore[11]
4239
) -> Uint32:
4340
"""Pack 4 Uint8 values into a Uint32 (little-endian: b0 is lowest byte)."""
4441
return Uint32(
@@ -71,10 +68,8 @@ def pack_4xu8_to_u32(
7168
)
7269

7370

74-
# pyre-ignore[56]
7571
@dsl_user_op
7672
def store_u32_shared(
77-
# pyre-ignore[11]
7873
ptr: Int64,
7974
val: Uint32,
8075
*,
@@ -96,10 +91,8 @@ def store_u32_shared(
9691
)
9792

9893

99-
# pyre-ignore[56]
10094
@dsl_user_op
10195
def tanh(
102-
# pyre-ignore[11]
10396
a: float | Float32,
10497
*,
10598
loc: object | None = None,
@@ -118,7 +111,6 @@ def tanh(
118111
)
119112

120113

121-
# pyre-ignore[56]
122114
@dsl_user_op
123115
def max_f32(
124116
a: float | Float32,
@@ -141,7 +133,6 @@ def max_f32(
141133
)
142134

143135

144-
# pyre-ignore[56]
145136
@dsl_user_op
146137
def step_f32(
147138
x: float | Float32, *, loc: object | None = None, ip: object | None = None
@@ -162,7 +153,6 @@ def step_f32(
162153
)
163154

164155

165-
# pyre-ignore[56]
166156
@dsl_user_op
167157
def abs_f32(
168158
val: Float32, *, loc: object | None = None, ip: object | None = None
@@ -181,7 +171,6 @@ def abs_f32(
181171
)
182172

183173

184-
# pyre-ignore[56]
185174
@dsl_user_op
186175
def max3_f32(
187176
a: float | Float32,
@@ -213,7 +202,6 @@ def max3_f32(
213202
)
214203

215204

216-
# pyre-ignore[56]
217205
@dsl_user_op
218206
def mul_cvt_relu_8x_e4m3(
219207
in_0: Float32,
@@ -290,7 +278,6 @@ def mul_cvt_relu_8x_e4m3(
290278
)
291279

292280

293-
# pyre-ignore[56]
294281
@dsl_user_op
295282
def unpack_i64_to_u32_pair(
296283
packed: Int64, *, loc: object | None = None, ip: object | None = None
@@ -314,7 +301,6 @@ def unpack_i64_to_u32_pair(
314301
return lo, hi
315302

316303

317-
# pyre-ignore[56]
318304
@dsl_user_op
319305
def cvt_relu_8x_e4m3(
320306
s0: Float32,
@@ -377,7 +363,6 @@ def cvt_relu_8x_e4m3(
377363
)
378364

379365

380-
# pyre-ignore[56]
381366
@dsl_user_op
382367
def cvt_8x_e4m3(
383368
s0: Float32,
@@ -440,7 +425,6 @@ def cvt_8x_e4m3(
440425
)
441426

442427

443-
# pyre-ignore[56]
444428
@dsl_user_op
445429
def fused_amax_to_e8m0_scale_f32(
446430
amax: Float32,
@@ -524,7 +508,6 @@ class Relu:
524508
ReLU gradient: 1 if x >= 0, else 0
525509
"""
526510

527-
# pyre-ignore[11]
528511
def __init__(
529512
self,
530513
scale_qk: Float32,
@@ -533,19 +516,16 @@ def __init__(
533516
self.c_zero: object = (Float32(0.0), Float32(0.0))
534517
self.c_one: object = (Float32(1.0), Float32(1.0))
535518

536-
# pyre-ignore[56]
537519
@cute.jit
538520
def relu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
539521
"""Apply ReLU activation: max(0, x) for packed f32x2."""
540522
return (max_f32(x[0], Float32(0.0)), max_f32(x[1], Float32(0.0)))
541523

542-
# pyre-ignore[56]
543524
@cute.jit
544525
def grad_relu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
545526
"""Compute ReLU gradient: 1 if x >= 0, else 0 for packed f32x2."""
546527
return (step_f32(x[0]), step_f32(x[1]))
547528

548-
# pyre-ignore[56]
549529
@cute.jit
550530
def activation_and_gradient_relu(
551531
self, x: tuple[Float32, Float32]
@@ -556,17 +536,13 @@ def activation_and_gradient_relu(
556536
"""
557537
act = self.relu(x)
558538
grad = self.grad_relu(x)
559-
# pyre-ignore[60]
560539
return *act, *grad
561540

562-
# pyre-ignore[56]
563541
@cute.jit
564542
def relu_and_convert(
565543
self,
566-
# pyre-ignore[11]
567544
acc_S_row: cute.Tensor,
568545
acc_S_row_converted: cute.Tensor,
569-
# pyre-ignore[11]
570546
e2e_freq: cutlass.Constexpr[int] = 16,
571547
e2e_res: cutlass.Constexpr[int] = 4,
572548
e2e_frg_limit: cutlass.Constexpr[int] = 1,
@@ -591,7 +567,6 @@ def relu_and_convert(
591567
acc_S_row_frg[None, j].load().to(acc_S_row_converted.element_type)
592568
)
593569

594-
# pyre-ignore[56]
595570
@cute.jit
596571
def grad_relu_and_convert(
597572
self,
@@ -631,7 +606,6 @@ def grad_relu_and_convert(
631606
acc_P_row_frg[None, j].load().to(acc_P_row_f16_frg.element_type)
632607
)
633608

634-
# pyre-ignore[56]
635609
@cute.jit
636610
def relu_and_convert_blockscaled(
637611
self,
@@ -821,7 +795,6 @@ def relu_and_convert_blockscaled(
821795

822796

823797
class Gelu:
824-
# pyre-ignore[11]
825798
def __init__(
826799
self,
827800
scale_qk: Float32,
@@ -870,25 +843,18 @@ def __init__(
870843
Float32(0.0001171766272366646),
871844
)
872845
self.c_talyor_2_mul_c2: object = (
873-
# pyre-ignore[16]
874846
Float32(self.c_taylor_c2[0] * self.c_two[0]),
875-
# pyre-ignore[16]
876847
Float32(self.c_taylor_c2[1] * self.c_two[1]),
877848
)
878849
self.c_taylor_4_mul_c4: object = (
879-
# pyre-ignore[16]
880850
Float32(self.c_taylor_c4[0] * self.c_four[0]),
881-
# pyre-ignore[16]
882851
Float32(self.c_taylor_c4[1] * self.c_four[1]),
883852
)
884853
self.c_taylor_6_mul_c6: object = (
885-
# pyre-ignore[16]
886854
Float32(self.c_taylor_c6[0] * self.c_six[0]),
887-
# pyre-ignore[16]
888855
Float32(self.c_taylor_c6[1] * self.c_six[1]),
889856
)
890857

891-
# pyre-ignore[56]
892858
@cute.jit
893859
def gelu_tanh(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
894860
# x^2
@@ -906,7 +872,6 @@ def gelu_tanh(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
906872

907873
return (t_x, t_y)
908874

909-
# pyre-ignore[56]
910875
@cute.jit
911876
def activation_and_gradient_fast_gelu(
912877
self, x: tuple[Float32, Float32]
@@ -925,10 +890,8 @@ def activation_and_gradient_fast_gelu(
925890
grad = cute.arch.fma_packed_f32x2(tanh_1, self.c_half, term1)
926891
act = cute.arch.mul_packed_f32x2(half_x, tanh_1)
927892

928-
# pyre-ignore[60]
929893
return *act, *grad
930894

931-
# pyre-ignore[56]
932895
@cute.jit
933896
def fast_gelu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
934897
# TODO: Seems like the complier may be able to handle this, without explicitly calling packed_f32x2:
@@ -940,7 +903,6 @@ def fast_gelu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
940903
out = cute.arch.mul_packed_f32x2(out, tanh_1)
941904
return out
942905

943-
# pyre-ignore[56]
944906
@cute.jit
945907
def grad_fast_gelu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
946908
# TODO: Seems like the complier may be able to handle this, without explicitly calling packed_f32x2:
@@ -960,7 +922,6 @@ def grad_fast_gelu(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
960922
out = cute.arch.fma_packed_f32x2(one_plus_tanh, self.c_half, term1)
961923
return out
962924

963-
# pyre-ignore[56]
964925
@cute.jit
965926
def activation_and_gradient_gelu_taylor_deg6(
966927
self, x: tuple[Float32, Float32]
@@ -989,10 +950,8 @@ def activation_and_gradient_gelu_taylor_deg6(
989950

990951
grad = cute.arch.add_packed_f32x2(part1, part2)
991952
act = cute.arch.fma_packed_f32x2(x2, tmp, x_half) # 0.5*x + x2*tmp
992-
# pyre-ignore[60]
993953
return *act, *grad
994954

995-
# pyre-ignore[56]
996955
@cute.jit
997956
def grad_gelu_taylor_deg6(
998957
self, x: tuple[Float32, Float32]
@@ -1020,7 +979,6 @@ def grad_gelu_taylor_deg6(
1020979

1021980
return grad
1022981

1023-
# pyre-ignore[56]
1024982
@cute.jit
1025983
def gelu_taylor_deg6(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
1026984
# 0.5*x + x2*(c2 + x2*(c4 + x2*c6))
@@ -1033,7 +991,6 @@ def gelu_taylor_deg6(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32
1033991
out = cute.arch.fma_packed_f32x2(x2, tmp, x_half) # 0.5*x + x2*tmp
1034992
return out
1035993

1036-
# pyre-ignore[56]
1037994
@cute.jit
1038995
def gelu_taylor_deg10(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float32]:
1039996
# 0.5*x + x^2*(c2 + x^2*(c4 + x^2*(c6 + x^2*(c8 + x^2*c10))))
@@ -1048,7 +1005,6 @@ def gelu_taylor_deg10(self, x: tuple[Float32, Float32]) -> tuple[Float32, Float3
10481005
out = cute.arch.fma_packed_f32x2(x2, tmp, x_half) # 0.5*x + x^2*tmp
10491006
return out
10501007

1051-
# pyre-ignore[56]
10521008
@cute.jit
10531009
def gelu_and_convert(
10541010
self,
@@ -1085,7 +1041,6 @@ def gelu_and_convert(
10851041
acc_S_row_frg[None, j].load().to(acc_S_row_converted.element_type)
10861042
)
10871043

1088-
# pyre-ignore[56]
10891044
@cute.jit
10901045
def grad_gelu_and_convert(
10911046
self,
@@ -1135,7 +1090,6 @@ def grad_gelu_and_convert(
11351090
acc_P_row_frg[None, j].load().to(acc_P_row_f16_frg.element_type)
11361091
)
11371092

1138-
# pyre-ignore[56]
11391093
@cute.jit
11401094
def gelu_and_convert_blockscaled(
11411095
self,

gdpa/src/fast_math.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
from cutlass.cutlass_dsl import dsl_user_op, T # pyre-ignore[21]
3030

3131

32-
@cute.jit # pyre-ignore[56]
33-
# pyre-ignore[11]
32+
@cute.jit
3433
def clz(x: Int32) -> Int32:
3534
"""Count leading zeros in a 32-bit integer.
3635
@@ -59,15 +58,14 @@ def find_log2(x: Int32) -> Int32:
5958
return a + ((x & (x - 1)) != 0) # Round up, add 1 if not a power of 2.
6059

6160

62-
@dsl_user_op # pyre-ignore[56]
63-
# pyre-ignore[11]
61+
@dsl_user_op
6462
def umulhi(
6563
a: Int32,
6664
b: Int32,
6765
*,
6866
loc: object | None = None,
6967
ip: object | None = None,
70-
) -> Uint32: # pyre-ignore[11]
68+
) -> Uint32:
7169
"""Unsigned multiply-high: returns the upper 32 bits of the 64-bit product a*b.
7270
7371
Uses PTX mul.hi.u32 instruction.
@@ -92,14 +90,11 @@ class FastDivmod:
9290
with a multiply+shift on the GPU.
9391
"""
9492

95-
# pyre-ignore[11]
9693
divisor: Int32
97-
# pyre-ignore[11]
9894
multiplier: Uint32
99-
# pyre-ignore[11]
10095
shift_right: Uint32
10196
_loc: object | None
102-
_values_pos: list[int] # pyre-ignore[13]
97+
_values_pos: list[int]
10398

10499
def __init__(
105100
self,
@@ -110,9 +105,9 @@ def __init__(
110105
loc: object | None = None,
111106
ip: object | None = None,
112107
) -> None:
113-
self.divisor = divisor # pyre-ignore[4]
114-
self.multiplier = multipler # pyre-ignore[4]
115-
self.shift_right = shift_right # pyre-ignore[4]
108+
self.divisor = divisor
109+
self.multiplier = multipler
110+
self.shift_right = shift_right
116111
self._loc = loc
117112

118113
# called by host
@@ -132,15 +127,14 @@ def create(
132127
shift_right = Uint32(p - 32)
133128
return FastDivmod(divisor, multiplier, shift_right, loc=loc, ip=ip)
134129

135-
@cute.jit # pyre-ignore[56]
130+
@cute.jit
136131
def div(self, dividend: Int32) -> Int32:
137132
return (
138133
Int32(umulhi(dividend, self.multiplier) >> self.shift_right)
139134
if self.divisor != 1
140135
else dividend
141136
)
142137

143-
# pyre-ignore[11]
144138
def divmod(self, dividend: Int32) -> tuple[Int32, Int32]:
145139
quotient = self.div(dividend)
146140
remainder = dividend - quotient * self.divisor

gdpa/src/seqlen_info.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ class SeqlenInfo:
4141

4242
def __init__(
4343
self,
44-
# pyre-fixme[11]: Annotation `cutlass.Int32` is not defined as a type.
4544
batch_idx: cutlass.Int32,
4645
seqlen_static: cutlass.Int32,
47-
# pyre-fixme[11]: Annotation `cute.Tensor` is not defined as a type.
4846
cu_seqlens: cute.Tensor | None = None,
4947
seqused: cute.Tensor | None = None,
5048
) -> None:

0 commit comments

Comments
 (0)