[distributed] Remove python code older than 3.10 (#163613)

Because now that the minimum Python version is 3.10

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163613
Approved by: https://github.com/XuehaiPan, https://github.com/kwen2501
This commit is contained in:
Yuanyuan Chen 2025-09-28 04:15:21 +00:00 committed by PyTorch MergeBot
parent b377c9e365
commit c2862c8e66
2 changed files with 4 additions and 13 deletions

View File

@ -770,14 +770,9 @@ def _get_logs_specs_class(logs_specs_name: Optional[str]) -> type[LogsSpecs]:
logs_specs_cls = None logs_specs_cls = None
if logs_specs_name is not None: if logs_specs_name is not None:
eps = metadata.entry_points() eps = metadata.entry_points()
if hasattr(eps, "select"): # >= 3.10 group = eps.select(group="torchrun.logs_specs")
group = eps.select(group="torchrun.logs_specs") if group.select(name=logs_specs_name):
if group.select(name=logs_specs_name): logs_specs_cls = group[logs_specs_name].load()
logs_specs_cls = group[logs_specs_name].load()
elif specs := eps.get("torchrun.logs_specs"): # < 3.10
if entrypoint_list := [ep for ep in specs if ep.name == logs_specs_name]:
logs_specs_cls = entrypoint_list[0].load()
if logs_specs_cls is None: if logs_specs_cls is None:
raise ValueError( raise ValueError(

View File

@ -368,11 +368,7 @@ class Shard(Placement):
return f"S({self.dim})" return f"S({self.dim})"
# kw_only is only available in python >= 3.10 @dataclass(frozen=True, kw_only=True)
kw_only_dataclass = dict(kw_only=True) if "kw_only" in dataclass.__kwdefaults__ else {}
@dataclass(frozen=True, **kw_only_dataclass)
class _StridedShard(Shard): class _StridedShard(Shard):
""" """
_StridedShard is only introduced to support 2D FSDP2 + TP sharding where the tensor _StridedShard is only introduced to support 2D FSDP2 + TP sharding where the tensor