Skip to content

Enable Consistent SHA256 Hashing with reduced Planner Context #3091

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

Conversation

aporialiao
Copy link
Member

Summary:
Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:

  • enumerator.enumerate(...)'s output - which is used as the search_space in both LP and OSS planner
    • We are storing the output of enumerate as an attribute last_stored_search_space. This assumes enumerate will have been called before we hash the planner context inputs.
  • StorageResveration's policy (aka whether HeuristicalStorageReservation is used or FixedStorageReservation
  • StorageResveration's initialization attributes:
    • _percentage
    • _parameter_multiplier for HeuristicalStorageReservation
    • _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:

  • hash_planner_context_inputs to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
  • hash_sha256_to_int to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748

@facebook-github-bot facebook-github-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 Jun 13, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

2 similar comments
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

aporialiao added a commit to aporialiao/torchrec that referenced this pull request Jun 13, 2025
…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Reviewed By: micrain

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

…h#3091)

Summary:
Pull Request resolved: pytorch#3091

Even though SHA256 hashing is used, we're still not seeing the expected same hash generated from the original planner context inputs.

This problem is due to Enumerator and Storage Reservation objects we were originally trying to hash containing attributes that differ between processes/instances.

To resolve this we reduced the hashing context to only use the specific attributes we need from enumerator and storage reservation.
Namely:
* enumerator.enumerate(...)'s output - which is used as the `search_space` in both LP and OSS planner
    * We are storing the output of enumerate as an attribute `last_stored_search_space`. **This assumes enumerate will have been called before we hash the planner context inputs**.
* StorageResveration's policy (aka whether `HeuristicalStorageReservation` is used or `FixedStorageReservation`
* StorageResveration's initialization attributes:
    * _percentage
    * _parameter_multiplier for HeuristicalStorageReservation
    * _dense_tensor_estimate for HeuristicalStorageReservation

Created helper functions:
* `hash_planner_context_inputs` to be called in both planner.hash_planner_context_inputs and manifold loading call site (see D75723272)
* `hash_sha256_to_int` to be passed in as the default hash function in hash_planner_context_inputs

Also created a multiprocess unit test to quickly check if consistent hashes are being generated across different processes given the same input.

Reviewed By: micrain

Differential Revision: D76303748
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76303748

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants