From 06b9cc03bf98872875cc169cec33d5801a89ff0a Mon Sep 17 00:00:00 2001 From: "Pyre Bot Jr." Date: Tue, 20 Oct 2026 10:47:58 -0700 Subject: [PATCH] Remove unused type error suppressions (landing group 94) (#4492) Summary: X-link: https://github.com/meta-recsys/recir/pull/469 X-link: https://github.com/meta-pytorch/torchrec/pull/4915 Pull Request resolved: https://github.com/meta-pytorch/torchcomms/pull/4492 X-link: https://github.com/facebookresearch/FBGEMM/pull/3382 X-link: https://github.com/pytorch/pytorch/pull/201564 X-link: https://github.com/meta-pytorch/tnt/pull/1102 X-link: https://github.com/facebookresearch/DCPerf/pull/926 X-link: https://github.com/facebookincubator/MCGrad/pull/352 X-link: https://github.com/facebookexperimental/ptx-anneal/pull/7 X-link: https://github.com/facebook/Ax/pull/5305 This Phabricator Diff was generated from Pyrefly type-checker output by the per-target upgrade tool. It was not generated by an AI coding system. It changes only type-error suppression comments: it removes suppressions that are no longer needed and adds `# pyrefly: ignore[...]` comments for remaining errors. It does not change Python runtime behavior or application logic. Landing group: `a4aafcc16d82133483419621eafd44f23c4eacfecab0767af53ff3205d58abd5` (attempt 1, 18 batches, 901 files) Merged patch SHA-256: `00e21a920ceb543a54e214fecec9b48113a48969491c818d566d61aeb10ea3d5` Excluded sensitive files: 3 #pyreupgrade Reviewed By: maggiemoss Differential Revision: D126418570 --- comms/dsl/tuning_base.py | 6 ++-- .../benchmarks/nccl_comm_memory_runner.py | 8 ++--- .../ReductionNumericalMastCompareLauncher.py | 4 +-- comms/torchcomms/device_mesh.py | 12 ++++---- comms/torchcomms/distwrap/__init__.py | 2 -- comms/torchcomms/distwrap/collectives.py | 21 +++++++------ comms/torchcomms/distwrap/new_comm.py | 3 -- .../tests/integration/AllReduceTest.py | 2 ++ .../InitProcessGroupDefaultTest.py | 1 + .../InitProcessGroupDeviceIdTest.py | 1 + .../InitProcessGroupExplicitRankTest.py | 1 + .../InitProcessGroupExplicitTorchcommsTest.py | 1 + .../InitProcessGroupGroupNameTest.py | 1 + .../InitProcessGroupPgOptionsTest.py | 1 + ...ProcessGroupRankAndWorldSizeFromEnvTest.py | 1 + .../InitProcessGroupRankFromEnvTest.py | 1 + .../InitProcessGroupTimeoutTest.py | 1 + .../InitProcessGroupWorldSizeFromEnvTest.py | 1 + .../tests/integration/NewGroupTest.py | 1 + .../integration/ReduceScatterQuantizedTest.py | 2 ++ .../tests/integration/ReduceScatterTest.py | 30 +++++++++++++++---- .../distwrap/tests/integration/ReduceTest.py | 2 ++ .../tests/integration/SplitGroupTest.py | 3 ++ .../tests/integration/test_helpers.py | 2 +- comms/torchcomms/distwrap/utils.py | 1 - comms/torchcomms/hooks/nan_check/nan_check.py | 1 - comms/torchcomms/objcol.py | 4 +-- .../helpers/py/cuda_graph_test_helpers.py | 6 +--- .../tests/helpers/py/test_helpers.py | 1 - .../integration/py/CudaGraphsWindowTest.py | 2 +- .../tests/integration/py/DPTPCommTest.py | 1 - .../unit/py/DebugServerFlightRecorderTest.py | 2 -- 32 files changed, 74 insertions(+), 52 deletions(-) diff --git a/comms/dsl/tuning_base.py b/comms/dsl/tuning_base.py index 19f41b9c55..5785f36a67 100644 --- a/comms/dsl/tuning_base.py +++ b/comms/dsl/tuning_base.py @@ -172,12 +172,10 @@ def check_geometry( # The cache advances only on an accepted switch: reseeding the baseline before the raise # would let the next (still hazardous) switch slip through unflagged. if prev is None or prev == sig: - transport._last_geometry_signature = ( - sig # pyre-ignore[16]: runtime cache on the transport - ) + transport._last_geometry_signature = sig return if os.environ.get("COMMS_DSL_ALLOW_GEOMETRY_SWITCH") == "1": - transport._last_geometry_signature = sig # pyre-ignore[16]: runtime cache + transport._last_geometry_signature = sig return names = sorted(fields) raise ValueError( diff --git a/comms/ncclx/meta/benchmarks/nccl_comm_memory_runner.py b/comms/ncclx/meta/benchmarks/nccl_comm_memory_runner.py index bd23967fa6..e0f4cf3683 100644 --- a/comms/ncclx/meta/benchmarks/nccl_comm_memory_runner.py +++ b/comms/ncclx/meta/benchmarks/nccl_comm_memory_runner.py @@ -1,7 +1,5 @@ -from comms.testinfra.multiproc_benchmark_runner import ( # pyre-ignore - run_nccl_distributed_test, -) -from windtunnel.benchmarks.python_benchmark_runner.benchmark import ( # pyre-ignore +from comms.testinfra.multiproc_benchmark_runner import run_nccl_distributed_test +from windtunnel.benchmarks.python_benchmark_runner.benchmark import ( main as servicelab_main, register_benchmark, UserCounters, @@ -14,7 +12,7 @@ @register_benchmark(use_counters=True) -def ncclCommMemoryMB(counters: UserCounters) -> None: # pyre-ignore +def ncclCommMemoryMB(counters: UserCounters) -> None: for ppn in [1, 4]: target = f"{TARGET_PREFIX}{ppn}" memory_mb = run_nccl_distributed_test(target, SEARCH_PATTERN) diff --git a/comms/ncclx/meta/tests/ReductionNumericalMastCompareLauncher.py b/comms/ncclx/meta/tests/ReductionNumericalMastCompareLauncher.py index 17fbd3a53a..c595332d55 100644 --- a/comms/ncclx/meta/tests/ReductionNumericalMastCompareLauncher.py +++ b/comms/ncclx/meta/tests/ReductionNumericalMastCompareLauncher.py @@ -23,9 +23,9 @@ parse_actual_outputs, print_numerical_failure_summary, ) -from torchx.components.fb.dist import hpc as fb_dist_hpc # pyre-ignore[21] +from torchx.components.fb.dist import hpc as fb_dist_hpc from torchx.runner import get_runner # pyre-ignore[21] -from torchx.specs import CfgVal, named_resources # pyre-ignore[21] +from torchx.specs import CfgVal, named_resources logger: logging.Logger = logging.getLogger(__name__) diff --git a/comms/torchcomms/device_mesh.py b/comms/torchcomms/device_mesh.py index 35cb373582..469071617c 100644 --- a/comms/torchcomms/device_mesh.py +++ b/comms/torchcomms/device_mesh.py @@ -198,7 +198,7 @@ def _flatten_with_comm( else: from torch.distributed._mesh_layout import _MeshLayout - coalesced_layout = _MeshLayout([layout.collapse()]) # pyre-ignore[19] + coalesced_layout = _MeshLayout([layout.collapse()]) # Compatibility layer for DeviceMesh API changes. The new API uses _rank_map # while the older API requires passing mesh tensor directly. This conditional @@ -235,11 +235,9 @@ def _flatten_with_comm( "Flattening with torchcomm is not supported for device mesh without mesh layout." ) root_mesh = _mesh_resources.get_root_mesh(mesh) - _mesh_resources.child_to_root_mapping[ # pyre-ignore[16] - flattened_device_mesh - ] = root_mesh - _mesh_resources.root_to_flatten_mapping.setdefault( # pyre-ignore[16] - root_mesh, {} - )[mesh_dim_name] = flattened_device_mesh + _mesh_resources.child_to_root_mapping[flattened_device_mesh] = root_mesh + _mesh_resources.root_to_flatten_mapping.setdefault(root_mesh, {})[ + mesh_dim_name + ] = flattened_device_mesh return flattened_device_mesh diff --git a/comms/torchcomms/distwrap/__init__.py b/comms/torchcomms/distwrap/__init__.py index f8ad751c31..ff989a7986 100644 --- a/comms/torchcomms/distwrap/__init__.py +++ b/comms/torchcomms/distwrap/__init__.py @@ -6,8 +6,6 @@ import torch import torch.distributed as dist - -# pyre-fixme[21]: Could not find name in module (ProcessGroup backends not in stubs) from torch.distributed import ( # noqa: F401 get_process_group_ranks, get_rank, diff --git a/comms/torchcomms/distwrap/collectives.py b/comms/torchcomms/distwrap/collectives.py index f771ca166c..2b8ae956a0 100644 --- a/comms/torchcomms/distwrap/collectives.py +++ b/comms/torchcomms/distwrap/collectives.py @@ -31,13 +31,21 @@ # Static mapping from torch.distributed.ReduceOp to torchcomms.ReduceOp _REDUCE_OP_MAP: dict[ReduceOp, TcReduceOp] = { + # pyrefly: ignore [bad-assignment] ReduceOp.SUM: TcReduceOp.SUM, + # pyrefly: ignore [bad-assignment] ReduceOp.PRODUCT: TcReduceOp.PRODUCT, + # pyrefly: ignore [bad-assignment] ReduceOp.MIN: TcReduceOp.MIN, + # pyrefly: ignore [bad-assignment] ReduceOp.MAX: TcReduceOp.MAX, + # pyrefly: ignore [bad-assignment] ReduceOp.BAND: TcReduceOp.BAND, + # pyrefly: ignore [bad-assignment] ReduceOp.BOR: TcReduceOp.BOR, + # pyrefly: ignore [bad-assignment] ReduceOp.BXOR: TcReduceOp.BXOR, + # pyrefly: ignore [bad-assignment] ReduceOp.AVG: TcReduceOp.AVG, } @@ -107,6 +115,7 @@ def _make_nccl_premul_sum(mul_factor: float | torch.Tensor) -> ReduceOp: def all_reduce( tensor: torch.Tensor, + # pyrefly: ignore [bad-function-definition] op: ReduceOp = ReduceOp.SUM, group: ProcessGroup | None = None, async_op: bool = False, @@ -154,6 +163,7 @@ def broadcast( def reduce( tensor: torch.Tensor, dst: int | None = None, + # pyrefly: ignore [bad-function-definition] op: ReduceOp = ReduceOp.SUM, group: ProcessGroup | None = None, async_op: bool = False, @@ -232,6 +242,7 @@ def all_gather_into_tensor( def reduce_scatter( output: torch.Tensor, input_list: list[torch.Tensor], + # pyrefly: ignore [bad-function-definition] op: ReduceOp = ReduceOp.SUM, group: ProcessGroup | None = None, async_op: bool = False, @@ -257,6 +268,7 @@ def reduce_scatter( def reduce_scatter_tensor( output: torch.Tensor, input: torch.Tensor, + # pyrefly: ignore [bad-function-definition] op: ReduceOp = ReduceOp.SUM, group: ProcessGroup | None = None, async_op: bool = False, @@ -536,24 +548,18 @@ def batch_isend_irecv(p2p_op_list: list[Any]) -> list[dist.Work]: return [] first_op = getattr(p2p_op_list[0], "_p2p_op", p2p_op_list[0]) - # pyrefly: ignore [missing-attribute] pg = get_group(first_op.group) pg_info_assert_registered(pg) - # pyrefly: ignore [missing-attribute] tc = get_torchcomms_instance(pg, tensor=first_op.tensor) works: list[dist.Work] = [] for p2p_op in p2p_op_list: actual_op = getattr(p2p_op, "_p2p_op", p2p_op) - # pyrefly: ignore [missing-attribute] op_name = actual_op.op.__name__ - # pyrefly: ignore [missing-attribute] group_peer = actual_op.group_peer if group_peer is None: - # pyrefly: ignore [missing-attribute] if actual_op.peer is not None: - # pyrefly: ignore [bad-argument-type] group_peer = get_group_rank(pg, actual_op.peer) else: raise ValueError( @@ -562,10 +568,8 @@ def batch_isend_irecv(p2p_op_list: list[Any]) -> list[dist.Work]: ) if "send" in op_name: - # pyrefly: ignore [missing-attribute] work = tc.send(actual_op.tensor, group_peer, True) elif "recv" in op_name: - # pyrefly: ignore [missing-attribute] work = tc.recv(actual_op.tensor, group_peer, True) else: raise ValueError(f"Unknown P2P operation: {op_name}") @@ -573,7 +577,6 @@ def batch_isend_irecv(p2p_op_list: list[Any]) -> list[dist.Work]: return works # Unwrap distwrap P2POp objects to torch.distributed.P2POp unwrapped_ops = [getattr(op, "_p2p_op", op) for op in p2p_op_list] - # pyrefly: ignore [bad-argument-type] works = dist.batch_isend_irecv(unwrapped_ops) if works is None: raise AssertionError("dist.batch_isend_irecv returned None") diff --git a/comms/torchcomms/distwrap/new_comm.py b/comms/torchcomms/distwrap/new_comm.py index 7b324ca506..8ed835577c 100644 --- a/comms/torchcomms/distwrap/new_comm.py +++ b/comms/torchcomms/distwrap/new_comm.py @@ -318,12 +318,9 @@ def split_group( # noqa: C901 # NCCL options, we set split_share=0 on them. If the user passes # non-NCCL options (e.g., Gloo), we pass them through unchanged. # - # pyre-fixme[16]: Module `torch.distributed` has no attribute `ProcessGroupNCCL`. if hasattr(dist, "ProcessGroupNCCL"): if pg_options is None: - # pyre-fixme[16]: Module `torch.distributed` has no attribute `ProcessGroupNCCL`. pg_options = dist.ProcessGroupNCCL.Options() - # pyre-fixme[16]: Module `torch.distributed` has no attribute `ProcessGroupNCCL`. if isinstance(pg_options, dist.ProcessGroupNCCL.Options): if hasattr(pg_options, "config") and hasattr( pg_options.config, "split_share" diff --git a/comms/torchcomms/distwrap/tests/integration/AllReduceTest.py b/comms/torchcomms/distwrap/tests/integration/AllReduceTest.py index 89121ca7b9..7d85904e4c 100644 --- a/comms/torchcomms/distwrap/tests/integration/AllReduceTest.py +++ b/comms/torchcomms/distwrap/tests/integration/AllReduceTest.py @@ -45,6 +45,7 @@ def test_sync_all_reduce(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 @@ -59,6 +60,7 @@ def test_async_all_reduce(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] work = dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=True) if work is None: raise AssertionError("work is None") diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDefaultTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDefaultTest.py index b009b2d2ba..c537ef297e 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDefaultTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDefaultTest.py @@ -33,6 +33,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDeviceIdTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDeviceIdTest.py index a50edf6e2f..df394e3ad5 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDeviceIdTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupDeviceIdTest.py @@ -38,6 +38,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitRankTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitRankTest.py index ca957478b7..2ede32607d 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitRankTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitRankTest.py @@ -39,6 +39,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitTorchcommsTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitTorchcommsTest.py index de5048330e..b8c069b4e3 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitTorchcommsTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupExplicitTorchcommsTest.py @@ -34,6 +34,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupGroupNameTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupGroupNameTest.py index 882458daca..a246038501 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupGroupNameTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupGroupNameTest.py @@ -36,6 +36,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupPgOptionsTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupPgOptionsTest.py index 7195cac40b..27c9cc8ad4 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupPgOptionsTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupPgOptionsTest.py @@ -42,6 +42,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankAndWorldSizeFromEnvTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankAndWorldSizeFromEnvTest.py index 1deee6eb6f..270cc03d7f 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankAndWorldSizeFromEnvTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankAndWorldSizeFromEnvTest.py @@ -37,6 +37,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankFromEnvTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankFromEnvTest.py index 177fc8612b..5e1c48e353 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankFromEnvTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupRankFromEnvTest.py @@ -37,6 +37,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupTimeoutTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupTimeoutTest.py index dbfa8384d9..10d01d3281 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupTimeoutTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupTimeoutTest.py @@ -37,6 +37,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupWorldSizeFromEnvTest.py b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupWorldSizeFromEnvTest.py index 59c35cf4d6..74bfd1f71f 100644 --- a/comms/torchcomms/distwrap/tests/integration/InitProcessGroupWorldSizeFromEnvTest.py +++ b/comms/torchcomms/distwrap/tests/integration/InitProcessGroupWorldSizeFromEnvTest.py @@ -37,6 +37,7 @@ def test(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * ( rank + 1 ) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/NewGroupTest.py b/comms/torchcomms/distwrap/tests/integration/NewGroupTest.py index a6079f71f6..982face607 100644 --- a/comms/torchcomms/distwrap/tests/integration/NewGroupTest.py +++ b/comms/torchcomms/distwrap/tests/integration/NewGroupTest.py @@ -58,6 +58,7 @@ def _verify_collective(self, pg: dist.ProcessGroup) -> None: device = get_device(rank) input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, group=pg, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/ReduceScatterQuantizedTest.py b/comms/torchcomms/distwrap/tests/integration/ReduceScatterQuantizedTest.py index f695abe898..cf295385b1 100644 --- a/comms/torchcomms/distwrap/tests/integration/ReduceScatterQuantizedTest.py +++ b/comms/torchcomms/distwrap/tests/integration/ReduceScatterQuantizedTest.py @@ -74,6 +74,7 @@ def test_reduce_scatter_quantized_sum(self) -> None: work = dist.reduce_scatter_quantized( output_tensor, input_tensor, + # pyrefly: ignore [bad-argument-type] dist.ReduceOp.SUM, seed, async_op=False, @@ -109,6 +110,7 @@ def test_reduce_scatter_quantized_async(self) -> None: work = dist.reduce_scatter_quantized( output_tensor, input_tensor, + # pyrefly: ignore [bad-argument-type] dist.ReduceOp.SUM, seed, async_op=True, diff --git a/comms/torchcomms/distwrap/tests/integration/ReduceScatterTest.py b/comms/torchcomms/distwrap/tests/integration/ReduceScatterTest.py index 65d617bbaa..9bc3d0b9e0 100644 --- a/comms/torchcomms/distwrap/tests/integration/ReduceScatterTest.py +++ b/comms/torchcomms/distwrap/tests/integration/ReduceScatterTest.py @@ -52,7 +52,11 @@ def test_sync_reduce_scatter(self) -> None: output_tensor = torch.zeros(1024, dtype=torch.float, device=device) dist.reduce_scatter( - output_tensor, input_list, op=dist.ReduceOp.SUM, async_op=False + # pyrefly: ignore [bad-argument-type] + output_tensor, + input_list, + op=dist.ReduceOp.SUM, + async_op=False, ) # Each rank gets the sum of all ranks' contribution for its chunk @@ -73,7 +77,11 @@ def test_async_reduce_scatter(self) -> None: output_tensor = torch.zeros(1024, dtype=torch.float, device=device) work = dist.reduce_scatter( - output_tensor, input_list, op=dist.ReduceOp.SUM, async_op=True + # pyrefly: ignore [bad-argument-type] + output_tensor, + input_list, + op=dist.ReduceOp.SUM, + async_op=True, ) if work is None: raise AssertionError("work is None") @@ -95,7 +103,11 @@ def test_sync_reduce_scatter_tensor(self) -> None: output_tensor = torch.zeros(1024, dtype=torch.float, device=device) dist.reduce_scatter_tensor( - output_tensor, input_tensor, op=dist.ReduceOp.SUM, async_op=False + # pyrefly: ignore [bad-argument-type] + output_tensor, + input_tensor, + op=dist.ReduceOp.SUM, + async_op=False, ) expected = num_ranks * (num_ranks + 1) // 2 @@ -114,7 +126,11 @@ def test_async_reduce_scatter_tensor(self) -> None: output_tensor = torch.zeros(1024, dtype=torch.float, device=device) work = dist.reduce_scatter_tensor( - output_tensor, input_tensor, op=dist.ReduceOp.SUM, async_op=True + # pyrefly: ignore [bad-argument-type] + output_tensor, + input_tensor, + op=dist.ReduceOp.SUM, + async_op=True, ) if work is None: raise AssertionError("work is None") @@ -141,7 +157,11 @@ def test_reduce_scatter_variable_sizes(self) -> None: output_tensor = torch.zeros(output_size, dtype=torch.float, device=device) dist.reduce_scatter( - output_tensor, input_list, op=dist.ReduceOp.SUM, async_op=False + # pyrefly: ignore [bad-argument-type] + output_tensor, + input_list, + op=dist.ReduceOp.SUM, + async_op=False, ) # Each rank gets the sum of all ranks' contributions diff --git a/comms/torchcomms/distwrap/tests/integration/ReduceTest.py b/comms/torchcomms/distwrap/tests/integration/ReduceTest.py index b5f2b3d425..831386370c 100644 --- a/comms/torchcomms/distwrap/tests/integration/ReduceTest.py +++ b/comms/torchcomms/distwrap/tests/integration/ReduceTest.py @@ -47,6 +47,7 @@ def test_sync_reduce(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.reduce(input_tensor, dst=0, op=dist.ReduceOp.SUM, async_op=False) if rank == 0: @@ -62,6 +63,7 @@ def test_async_reduce(self) -> None: input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] work = dist.reduce(input_tensor, dst=0, op=dist.ReduceOp.SUM, async_op=True) if work is None: raise AssertionError("work is None") diff --git a/comms/torchcomms/distwrap/tests/integration/SplitGroupTest.py b/comms/torchcomms/distwrap/tests/integration/SplitGroupTest.py index 567bf0a2c5..da54565d8d 100644 --- a/comms/torchcomms/distwrap/tests/integration/SplitGroupTest.py +++ b/comms/torchcomms/distwrap/tests/integration/SplitGroupTest.py @@ -57,6 +57,7 @@ def _verify_collective(self, pg: dist.ProcessGroup) -> None: device = get_device(rank) input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, group=pg, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 @@ -107,6 +108,7 @@ def test_split_group_collective(self) -> None: # Test all_reduce on the new group input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, group=new_pg, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 @@ -134,6 +136,7 @@ def test_split_group_with_backend(self) -> None: # Test all_reduce on the new group with explicit backend input_tensor = torch.ones(1024, dtype=torch.float, device=device) * (rank + 1) + # pyrefly: ignore [bad-argument-type] dist.all_reduce(input_tensor, dist.ReduceOp.SUM, group=new_pg, async_op=False) expected = num_ranks * (num_ranks + 1) // 2 diff --git a/comms/torchcomms/distwrap/tests/integration/test_helpers.py b/comms/torchcomms/distwrap/tests/integration/test_helpers.py index 827f187972..c6c66bf6b6 100644 --- a/comms/torchcomms/distwrap/tests/integration/test_helpers.py +++ b/comms/torchcomms/distwrap/tests/integration/test_helpers.py @@ -34,6 +34,7 @@ def get_op_name(op: dist.ReduceOp) -> str: dist.ReduceOp.BXOR: "BXor", dist.ReduceOp.AVG: "Avg", } + # pyrefly: ignore [no-matching-overload] return op_names.get(op, f"Unknown: {op}") @@ -98,7 +99,6 @@ def get_pg_options(backend: str) -> object | None: doesn't have a supported options class. """ if backend in ["nccl", "ncclx"]: - # pyre-ignore[16]: ProcessGroupNCCL not in Pyre stubs return dist.ProcessGroupNCCL.Options() elif backend in ["gloo"]: # pyre-ignore[16]: ProcessGroupGloo not in Pyre stubs diff --git a/comms/torchcomms/distwrap/utils.py b/comms/torchcomms/distwrap/utils.py index 2d900d7930..ca5661a68d 100644 --- a/comms/torchcomms/distwrap/utils.py +++ b/comms/torchcomms/distwrap/utils.py @@ -412,7 +412,6 @@ def _pg_options_to_hints(pg_options: Any | None) -> dict[str, str] | None: # no if hasattr(pg_options, "config"): # Extract config attributes config = pg_options.config - # pyre-ignore[16]: ProcessGroupNCCL may not be available process_group_nccl = getattr(dist, "ProcessGroupNCCL", None) if process_group_nccl is not None: nccl_config_class = getattr(process_group_nccl, "NCCLConfig", None) diff --git a/comms/torchcomms/hooks/nan_check/nan_check.py b/comms/torchcomms/hooks/nan_check/nan_check.py index 6903850533..4f1de266aa 100644 --- a/comms/torchcomms/hooks/nan_check/nan_check.py +++ b/comms/torchcomms/hooks/nan_check/nan_check.py @@ -28,7 +28,6 @@ # The op is registered when torch.distributed is imported (which happens # before any communicator is created), so we resolve on first use to # avoid a circular import at module load time. -# pyre-ignore[5]: Global has no type annotation. _check_for_nan = None diff --git a/comms/torchcomms/objcol.py b/comms/torchcomms/objcol.py index bf5ebf74d1..78c53a57f3 100644 --- a/comms/torchcomms/objcol.py +++ b/comms/torchcomms/objcol.py @@ -561,9 +561,9 @@ def broadcast_object_list( # has only one element, we can skip the copy. if my_comm_rank == root: if len(tensor_list) == 1: # type: ignore[possibly-undefined] - object_tensor = tensor_list[0] # pyre-fixme[61] + object_tensor = tensor_list[0] else: - object_tensor = torch.cat(tensor_list) # pyre-fixme[61] + object_tensor = torch.cat(tensor_list) else: object_tensor = torch.empty( # type: ignore[call-overload] torch.sum(object_sizes_tensor).item(), # type: ignore[arg-type] diff --git a/comms/torchcomms/tests/helpers/py/cuda_graph_test_helpers.py b/comms/torchcomms/tests/helpers/py/cuda_graph_test_helpers.py index 6bd7d1a6ed..cd8dc6e5ce 100644 --- a/comms/torchcomms/tests/helpers/py/cuda_graph_test_helpers.py +++ b/comms/torchcomms/tests/helpers/py/cuda_graph_test_helpers.py @@ -17,12 +17,10 @@ import torch import torchcomms -# pyre-fixme[5]: Global annotation for skip decorator. skip_unless_ncclx = unittest.skipIf( os.getenv("TEST_BACKEND") != "ncclx", "Skipping NCCLX-only tests" ) -# pyre-fixme[21]: Could not find name `ProfilerActivity` in `torch.profiler`. from torch.profiler import profile, ProfilerActivity from torchcomms.tests.integration.helpers.TorchCommTestHelpers import get_rank_and_size @@ -134,7 +132,7 @@ def probe_tensor_addr( assert probe.dtype == torch.int64 and probe.numel() >= 1 stream = torch.cuda.current_stream().cuda_stream - _cpp_write_addr(buf.data_ptr(), probe.data_ptr(), stream) # pyre-ignore[16] + _cpp_write_addr(buf.data_ptr(), probe.data_ptr(), stream) def _wait(work: object | None) -> None: @@ -465,10 +463,8 @@ def _run( # noqa: C901 profile_ctx = ( profile( activities=[ - # pyre-fixme[16]: Module `torch.profiler` has no # attribute `ProfilerActivity`. ProfilerActivity.CPU, - # pyre-fixme[16]: Module `torch.profiler` has no # attribute `ProfilerActivity`. ProfilerActivity.CUDA, ], diff --git a/comms/torchcomms/tests/helpers/py/test_helpers.py b/comms/torchcomms/tests/helpers/py/test_helpers.py index e7d54a9ebb..301742a79e 100644 --- a/comms/torchcomms/tests/helpers/py/test_helpers.py +++ b/comms/torchcomms/tests/helpers/py/test_helpers.py @@ -6,7 +6,6 @@ from torchcomms.functional import is_torch_compile_supported_and_enabled -# pyre-fixme[5]: Global annotation for skip decorator. skip_if_ncclx = unittest.skipIf( os.getenv("TEST_BACKEND") == "ncclx", "Skipping tests for NCCLX backend." ) diff --git a/comms/torchcomms/tests/integration/py/CudaGraphsWindowTest.py b/comms/torchcomms/tests/integration/py/CudaGraphsWindowTest.py index aec4bfd0af..1722c50bef 100644 --- a/comms/torchcomms/tests/integration/py/CudaGraphsWindowTest.py +++ b/comms/torchcomms/tests/integration/py/CudaGraphsWindowTest.py @@ -364,7 +364,7 @@ def test_device_window_memory_reuse_during_capture(self) -> None: if has_device_api: self.assertIsInstance(dev_win_ptr, int) # pyre-ignore[61] self.assertNotEqual( - dev_win_ptr, # pyre-ignore[61] + dev_win_ptr, 0, "Device window pointer should be non-zero", ) diff --git a/comms/torchcomms/tests/integration/py/DPTPCommTest.py b/comms/torchcomms/tests/integration/py/DPTPCommTest.py index f1643cd4c5..f54a82d1ca 100644 --- a/comms/torchcomms/tests/integration/py/DPTPCommTest.py +++ b/comms/torchcomms/tests/integration/py/DPTPCommTest.py @@ -88,7 +88,6 @@ def parallelize( if isinstance(module, nn.LayerNorm): continue if use_activation_checkpointing: - # pyrefly: ignore [invalid-param-spec] checkpoint(module) fully_shard(module, mesh=dp_mesh, **fsdp_kwargs) fully_shard(self, mesh=dp_mesh, **fsdp_kwargs) diff --git a/comms/torchcomms/tests/unit/py/DebugServerFlightRecorderTest.py b/comms/torchcomms/tests/unit/py/DebugServerFlightRecorderTest.py index dee20d2fe4..3142048289 100644 --- a/comms/torchcomms/tests/unit/py/DebugServerFlightRecorderTest.py +++ b/comms/torchcomms/tests/unit/py/DebugServerFlightRecorderTest.py @@ -29,8 +29,6 @@ from requests.adapters import HTTPAdapter from torch.distributed.debug import start_debug_server, stop_debug_server from torchcomms.hooks import FlightRecorderHook - -# pyre-fixme[21]: Could not find module `urllib3.util.retry`. from urllib3.util.retry import Retry