Commit c267634
Fix cpu_offloaded_metric_module type-check for new_group return (#4457)
Summary:
Pull Request resolved: #4457
Removing the TorchComms `new_group` -> `split_group` delegation in
`distributed_c10d.py` (D113127841 / pytorch#189071) leaves `_new_group_with_tag`
as `new_group`'s only return path. `new_group` has no explicit return
annotation, so Pyrefly now infers `ProcessGroup | int | None` (the `int` is the
`GroupMember.NON_GROUP_MEMBER == -100` sentinel) instead of the narrower type it
used to see.
`cpu_offloaded_metric_module.py` assigns `dist.new_group(backend="gloo")`
straight into an attribute typed `Optional[ProcessGroup]`, which no longer
type-checks:
cpu_offloaded_metric_module.py:303 `ProcessGroup | int | None` is not
assignable to attribute `cpu_process_group` with type `ProcessGroup | None`
Both call sites pass `ranks=None`, so every rank is a member and the result is
always a real `ProcessGroup` (never `NON_GROUP_MEMBER`); narrow the value with
`cast`. This is an internal-only, monorepo-coexistence break: OSS pytorch CI does
not type-check torchrec against the new signature, which is why pytorch#189071
was green on GitHub. Kept as a separate diff so the DiffTrain import stays
byte-identical to GitHub.
Reviewed By: dboyda
Differential Revision: D113289735
fbshipit-source-id: 0f3dba9c0fd80fced2902dd0bc507f4704af42911 parent c05a4d7 commit c267634
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
| 302 | + | |
302 | 303 | | |
303 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
304 | 307 | | |
305 | 308 | | |
306 | 309 | | |
| |||
755 | 758 | | |
756 | 759 | | |
757 | 760 | | |
758 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
759 | 764 | | |
760 | 765 | | |
761 | 766 | | |
| |||
0 commit comments