-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add device argument in the deserialization function #2041
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request was exported from Phabricator. Differential Revision: D57808349 |
TroyGarden
added a commit
to TroyGarden/torchrec
that referenced
this pull request
May 25, 2024
Summary: # context * current deserialization on the serialized embedding modules (from torch.export) will place the modules on the default device * we would like to add more control over the desrialization function so that we can specify on which device we would like the deserialized modules be * the rationale behind this is that we often want the deserialized module on a **meta** device, and then shard the module (basically replace the module with a sharded version). * by doing this it can save the cost of creating an actual deserialized module on a CPU or GPU device. # changes 1. we added an optional argument `device` to the `SerializerInterface` class, so that all the serializer should follow the same sematics 2. the default value is `None`, and we are expecting **this default value would always lead to the same behavior** as prior to this change 3. modified the `deserialize` function for `EBCJsonSerializer`, and confirmed that if the given `device` argument is `None`, the logic should be the same as before 4. modified the `deserialize` function for `PEAThriftSerializer`, and confirmed that the`__init__` function for `PositionWeightedModulePEA` and `PooledEmbeddingArch` both have default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` # reference 1. [code search](https://fburl.com/code/1jyxadpi) for the `SerializerInterface` {F1649407030} Differential Revision: D57808349
11eacad
to
af7d398
Compare
This pull request was exported from Phabricator. Differential Revision: D57808349 |
TroyGarden
added a commit
to TroyGarden/torchrec
that referenced
this pull request
May 25, 2024
Summary: # context * current deserialization on the serialized embedding modules (from torch.export) will place the modules on the default device * we would like to add more control over the desrialization function so that we can specify on which device we would like the deserialized modules be * the rationale behind this is that we often want the deserialized module on a **meta** device, and then shard the module (basically replace the module with a sharded version). * by doing this it can save the cost of creating an actual deserialized module on a CPU or GPU device. # changes 1. we added an optional argument `device` to the `SerializerInterface` class, so that all the serializer should follow the same sematics 2. the default value is `None`, and we are expecting **this default value would always lead to the same behavior** as prior to this change 3. modified the `deserialize` function for `EBCJsonSerializer`, and confirmed that if the given `device` argument is `None`, the logic should be the same as before 4. modified the `deserialize` function for `PEAThriftSerializer`, and confirmed that the`__init__` function for `PositionWeightedModulePEA` and `PooledEmbeddingArch` both have default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` # reference 1. [code search](https://fburl.com/code/1jyxadpi) for the `SerializerInterface` {F1649407030} Differential Revision: D57808349
af7d398
to
ee0e42d
Compare
This pull request was exported from Phabricator. Differential Revision: D57808349 |
TroyGarden
added a commit
to TroyGarden/torchrec
that referenced
this pull request
May 25, 2024
Summary: # context * current deserialization on the serialized embedding modules (from torch.export) will place the modules on the default device * we would like to add more control over the desrialization function so that we can specify on which device we would like the deserialized modules be * the rationale behind this is that we often want the deserialized module on a **meta** device, and then shard the module (basically replace the module with a sharded version). * by doing this it can save the cost of creating an actual deserialized module on a CPU or GPU device. # changes 1. we added an optional argument `device` to the `SerializerInterface` class, so that all the serializer should follow the same sematics 2. the default value is `None`, and we are expecting **this default value would always lead to the same behavior** as prior to this change 3. modified the `deserialize` function for `EBCJsonSerializer`, and confirmed that if the given `device` argument is `None`, the logic should be the same as before 4. modified the `deserialize` function for `PEAThriftSerializer`, and confirmed that the`__init__` function for `PositionWeightedModulePEA` and `PooledEmbeddingArch` both have default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` # reference 1. [code search](https://fburl.com/code/1jyxadpi) for the `SerializerInterface` {F1649407030} Differential Revision: D57808349
ee0e42d
to
fa9b948
Compare
This pull request was exported from Phabricator. Differential Revision: D57808349 |
Summary: # context * current deserialization on the serialized embedding modules (from torch.export) will place the modules on the default device * we would like to add more control over the desrialization function so that we can specify on which device we would like the deserialized modules be * the rationale behind this is that we often want the deserialized module on a **meta** device, and then shard the module (basically replace the module with a sharded version). * by doing this it can save the cost of creating an actual deserialized module on a CPU or GPU device. # changes 1. we added an optional argument `device` to the `SerializerInterface` class, so that all the serializer should follow the same sematics 2. the default value is `None`, and we are expecting **this default value would always lead to the same behavior** as prior to this change 3. modified the `deserialize` function for `EBCJsonSerializer`, and confirmed that if the given `device` argument is `None`, the logic should be the same as before 4. modified the `deserialize` function for `PEAThriftSerializer`, and confirmed that the`__init__` function for `PositionWeightedModulePEA` and `PooledEmbeddingArch` both have default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` # reference 1. [code search](https://fburl.com/code/1jyxadpi) for the `SerializerInterface` {F1649407030} Reviewed By: PaulZhang12 Differential Revision: D57808349
fa9b948
to
f3e5572
Compare
This pull request was exported from Phabricator. Differential Revision: D57808349 |
PaulZhang12
pushed a commit
that referenced
this pull request
Jun 5, 2024
Summary: Pull Request resolved: #2041 # context * current deserialization on the serialized embedding modules (from torch.export) will place the modules on the default device * we would like to add more control over the desrialization function so that we can specify on which device we would like the deserialized modules be * the rationale behind this is that we often want the deserialized module on a **meta** device, and then shard the module (basically replace the module with a sharded version). * by doing this it can save the cost of creating an actual deserialized module on a CPU or GPU device. # changes 1. we added an optional argument `device` to the `SerializerInterface` class, so that all the serializer should follow the same sematics 2. the default value is `None`, and we are expecting **this default value would always lead to the same behavior** as prior to this change 3. modified the `deserialize` function for `EBCJsonSerializer`, and confirmed that if the given `device` argument is `None`, the logic should be the same as before 4. modified the `deserialize` function for `PEAThriftSerializer`, and confirmed that the`__init__` function for `PositionWeightedModulePEA` and `PooledEmbeddingArch` both have default for `device=None` 5. modified the `deserialize` function for `EBCThriftSerializer`, and confirmed that the`__init__` function for `EmbeddingBagCollection` has default for `device=None` # reference 1. [code search](https://fburl.com/code/1jyxadpi) for the `SerializerInterface` {F1649407030} Reviewed By: PaulZhang12 Differential Revision: D57808349 fbshipit-source-id: 32aab00222581269d82568de491ba55af94033d4
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
context
changes
device
to theSerializerInterface
class, so that all the serializer should follow the same sematicsNone
, and we are expecting this default value would always lead to the same behavior as prior to this changedeserialize
function forEBCJsonSerializer
, and confirmed that if the givendevice
argument isNone
, the logic should be the same as beforedeserialize
function forPEAThriftSerializer
, and confirmed that the__init__
function forPositionWeightedModulePEA
andPooledEmbeddingArch
both have default fordevice=None
deserialize
function forEBCThriftSerializer
, and confirmed that the__init__
function forEmbeddingBagCollection
has default fordevice=None
deserialize
function forEBCThriftSerializer
, and confirmed that the__init__
function forEmbeddingBagCollection
has default fordevice=None
reference
SerializerInterface
{F1649407030}
Differential Revision: D57808349