From d70a19e9495a11abf1c054f3a9af5107b1362705 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005307016 Date: Fri, 13 Dec 2024 13:49:20 -0800 Subject: [PATCH] Add type error suppressions for upcoming upgrade (#3504) Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/584 Pull Request resolved: https://github.com/pytorch/FBGEMM/pull/3504 Reviewed By: Solumin Differential Revision: D67162164 fbshipit-source-id: 6a781090bbec3ef502a574d456cc6eddc3a260be --- fbgemm_gpu/test/quantize/common.py | 1 + fbgemm_gpu/test/quantize/fp8_rowwise_test.py | 1 + fbgemm_gpu/test/quantize/fused_8bit_rowwise_test.py | 1 + fbgemm_gpu/test/quantize/fused_nbit_rowwise_test.py | 1 + fbgemm_gpu/test/quantize/mixed_dim_int8_test.py | 1 + fbgemm_gpu/test/quantize/msfp_test.py | 1 + fbgemm_gpu/test/quantize/mx/common.py | 3 +++ fbgemm_gpu/test/quantize/mx4_test.py | 1 + fbgemm_gpu/test/tbe/cache/lxu_cache_test.py | 2 ++ 9 files changed, 12 insertions(+) diff --git a/fbgemm_gpu/test/quantize/common.py b/fbgemm_gpu/test/quantize/common.py index 6a720a1748..6a8108d548 100644 --- a/fbgemm_gpu/test/quantize/common.py +++ b/fbgemm_gpu/test/quantize/common.py @@ -16,6 +16,7 @@ import torch # pyre-fixme[16]: Module `fbgemm_gpu` has no attribute `open_source`. +# pyre-fixme[35]: Target cannot be annotated. open_source: bool = getattr(fbgemm_gpu, "open_source", False) try: diff --git a/fbgemm_gpu/test/quantize/fp8_rowwise_test.py b/fbgemm_gpu/test/quantize/fp8_rowwise_test.py index b3cc06a139..bb0cdbf362 100644 --- a/fbgemm_gpu/test/quantize/fp8_rowwise_test.py +++ b/fbgemm_gpu/test/quantize/fp8_rowwise_test.py @@ -22,6 +22,7 @@ # `deeplearning.fbgemm.fbgemm_gpu.test.quantize.common`. from .common import open_source +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_unavailable, optests, symint_vector_unsupported diff --git a/fbgemm_gpu/test/quantize/fused_8bit_rowwise_test.py b/fbgemm_gpu/test/quantize/fused_8bit_rowwise_test.py index a2183fcd94..7628d36ecb 100644 --- a/fbgemm_gpu/test/quantize/fused_8bit_rowwise_test.py +++ b/fbgemm_gpu/test/quantize/fused_8bit_rowwise_test.py @@ -25,6 +25,7 @@ open_source, ) +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_available diff --git a/fbgemm_gpu/test/quantize/fused_nbit_rowwise_test.py b/fbgemm_gpu/test/quantize/fused_nbit_rowwise_test.py index fa8823bfe9..19158f539f 100644 --- a/fbgemm_gpu/test/quantize/fused_nbit_rowwise_test.py +++ b/fbgemm_gpu/test/quantize/fused_nbit_rowwise_test.py @@ -25,6 +25,7 @@ open_source, ) +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_available, optests diff --git a/fbgemm_gpu/test/quantize/mixed_dim_int8_test.py b/fbgemm_gpu/test/quantize/mixed_dim_int8_test.py index a396871f72..8494493203 100644 --- a/fbgemm_gpu/test/quantize/mixed_dim_int8_test.py +++ b/fbgemm_gpu/test/quantize/mixed_dim_int8_test.py @@ -20,6 +20,7 @@ # `deeplearning.fbgemm.fbgemm_gpu.test.quantize.common`. from .common import open_source +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_unavailable diff --git a/fbgemm_gpu/test/quantize/msfp_test.py b/fbgemm_gpu/test/quantize/msfp_test.py index 1d81e2157a..2118f2dba8 100644 --- a/fbgemm_gpu/test/quantize/msfp_test.py +++ b/fbgemm_gpu/test/quantize/msfp_test.py @@ -18,6 +18,7 @@ # `deeplearning.fbgemm.fbgemm_gpu.test.quantize.common`. from .common import open_source +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_unavailable diff --git a/fbgemm_gpu/test/quantize/mx/common.py b/fbgemm_gpu/test/quantize/mx/common.py index 25d2ca847f..7b64039ff0 100644 --- a/fbgemm_gpu/test/quantize/mx/common.py +++ b/fbgemm_gpu/test/quantize/mx/common.py @@ -312,6 +312,7 @@ def check_diff_quantize( # Convert to numpy # pyre-fixme[9]: x has type `Tensor`; used as `Union[ndarray, Tensor]`. x = np.array(x) if type(x) is list else x + # pyre-fixme[9]: x has type `Tensor`; used as `Union[ndarray[Any, Any], Tensor]`. x = x.cpu().numpy() if type(x) is torch.Tensor else x y1 = y1.detach().cpu().numpy() y2 = y2.detach().cpu().numpy() @@ -334,11 +335,13 @@ def check_diff_quantize( where_diff = (diff != 0) | (torch_infs != cuda_infs) print("%d/%d mismatches" % (np.count_nonzero(where_diff), where_diff.size)) print("First and last mismatch:") + # pyre-fixme[6]: For 1st argument expected `float` but got `Tensor`. print("Orig:", x[where_diff][0], get_s_e_m(x[where_diff][0])) print("y1: ", y1[where_diff][0], get_s_e_m(y1[where_diff][0])) print("y2: ", y2[where_diff][0], get_s_e_m(y2[where_diff][0])) if np.count_nonzero(where_diff) > 1: print("--------------------") + # pyre-fixme[6]: For 1st argument expected `float` but got `Tensor`. print("Orig:", x[where_diff][-1], get_s_e_m(x[where_diff][-1])) print("y1: ", y1[where_diff][-1], get_s_e_m(y1[where_diff][-1])) print("y2: ", y2[where_diff][-1], get_s_e_m(y2[where_diff][-1])) diff --git a/fbgemm_gpu/test/quantize/mx4_test.py b/fbgemm_gpu/test/quantize/mx4_test.py index b7cbeeb6df..643e44fb90 100644 --- a/fbgemm_gpu/test/quantize/mx4_test.py +++ b/fbgemm_gpu/test/quantize/mx4_test.py @@ -34,6 +34,7 @@ check_diff_quantize, ) +# pyre-fixme[16]: Module `common` has no attribute `open_source`. if open_source: # pyre-ignore[21] from test_utils import gpu_unavailable diff --git a/fbgemm_gpu/test/tbe/cache/lxu_cache_test.py b/fbgemm_gpu/test/tbe/cache/lxu_cache_test.py index 89d7b96bc1..abe8ce99e2 100644 --- a/fbgemm_gpu/test/tbe/cache/lxu_cache_test.py +++ b/fbgemm_gpu/test/tbe/cache/lxu_cache_test.py @@ -171,6 +171,7 @@ def test_unique_lxu_cache_lookup( use_cpu=False, ).long() + # pyre-fixme[53]: Captured variable `lxu_cache_state` is not annotated. def unique_lookup( indices: Tensor, offsets: Tensor, @@ -197,6 +198,7 @@ def unique_lookup( return uniq_lxu_cache_locations, uniq_indices_length + # pyre-fixme[53]: Captured variable `lxu_cache_state` is not annotated. def duplicate_lookup( indices: Tensor, offsets: Tensor,