Skip to content
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
wants to merge 1 commit into from

Conversation

TroyGarden
Copy link
Contributor

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
  6. modified the deserialize function for EBCThriftSerializer, and confirmed that the__init__ function for EmbeddingBagCollection has default for device=None

reference

  1. code search for the SerializerInterface
    {F1649407030}

Differential Revision: D57808349

@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 May 25, 2024
@facebook-github-bot
Copy link
Contributor

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
@facebook-github-bot
Copy link
Contributor

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
@facebook-github-bot
Copy link
Contributor

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
@facebook-github-bot
Copy link
Contributor

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
@facebook-github-bot
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

2 participants