Skip to content

Conversation

@gregmacnamara
Copy link
Contributor

Summary:
This diff adds explicit __hash__ and __eq__ methods to custom objects in the torchrec planner that previously relied on Python's default object identity-based hashing.

  1. DeviceHardware (fbcode/torchrec/distributed/planner/types.py):
    • Hash based on rank, storage, and perf fields
    • Equality checks all three fields
  2. BasicCommsBandwidths (fbcode/torchrec/distributed/planner/types.py):
    • Hash based on inter_host_bw and intra_host_bw
    • Equality checks both bandwidth values

Reviewed By: iamzainhuda

Differential Revision: D85731424

Summary:
This diff adds explicit `__hash__` and `__eq__` methods to custom objects in the torchrec planner that previously relied on Python's default object identity-based hashing.


1. **DeviceHardware** (fbcode/torchrec/distributed/planner/types.py):
   - Hash based on rank, storage, and perf fields
   - Equality checks all three fields
2. **BasicCommsBandwidths** (fbcode/torchrec/distributed/planner/types.py):
   - Hash based on inter_host_bw and intra_host_bw
   - Equality checks both bandwidth values

Reviewed By: iamzainhuda

Differential Revision: D85731424
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 6, 2025
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Nov 6, 2025

@gregmacnamara has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85731424.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant