Skip to content

Add input dist to Perf #3138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions torchrec/distributed/planner/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Perf:
bwd_compute: float
bwd_comms: float
prefetch_compute: float = 0.0
input_dist: float = 0.0

@property
def total(self) -> float:
Expand All @@ -73,12 +74,17 @@ def total(self) -> float:
# benefit that 1) it enables the ScaleupProposer to explore the trade off
# between increasing cache sizes vs more difficult bin-packing constraints. 2)
# it helps balance the prefetch compute across the ranks.

# Similarly, input_dist is often overlapped with compute kernels, but we
# conservatively add it as part of the total cost which models it as blocking.

return (
self.fwd_compute
+ self.bwd_compute
+ self.fwd_comms
+ self.bwd_comms
+ self.prefetch_compute
+ self.input_dist
)

def __add__(self, other: "Perf") -> "Perf":
Expand All @@ -88,6 +94,7 @@ def __add__(self, other: "Perf") -> "Perf":
bwd_compute=self.bwd_compute + other.bwd_compute,
bwd_comms=self.bwd_comms + other.bwd_comms,
prefetch_compute=self.prefetch_compute + other.prefetch_compute,
input_dist=self.input_dist + other.input_dist,
)

def __hash__(self) -> int:
Expand All @@ -98,6 +105,7 @@ def __hash__(self) -> int:
self.bwd_compute,
self.bwd_comms,
self.prefetch_compute,
self.input_dist,
)
)

Expand Down
Loading