Skip to content

Commit

Permalink
Add EC ZCH to default sharder (pytorch#1610)
Browse files Browse the repository at this point in the history
Summary:

Added the EC ZCH module to the get_default_sharders method

Reviewed By: henrylhtsang

Differential Revision: D52541735
  • Loading branch information
PaulZhang12 authored and facebook-github-bot committed Jan 4, 2024
1 parent 3dbd472 commit dd155ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions torchrec/distributed/sharding_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
FeatureProcessedEmbeddingBagCollectionSharder,
)
from torchrec.distributed.fused_embeddingbag import FusedEmbeddingBagCollectionSharder
from torchrec.distributed.mc_embedding import ManagedCollisionEmbeddingCollectionSharder
from torchrec.distributed.mc_embeddingbag import (
ManagedCollisionEmbeddingBagCollectionSharder,
)
Expand All @@ -47,6 +48,7 @@ def get_default_sharders() -> List[ModuleSharder[nn.Module]]:
cast(ModuleSharder[nn.Module], QuantEmbeddingBagCollectionSharder()),
cast(ModuleSharder[nn.Module], QuantEmbeddingCollectionSharder()),
cast(ModuleSharder[nn.Module], ManagedCollisionEmbeddingBagCollectionSharder()),
cast(ModuleSharder[nn.Module], ManagedCollisionEmbeddingCollectionSharder()),
]


Expand Down
18 changes: 14 additions & 4 deletions torchrec/distributed/tests/test_sharding_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
FusedEmbeddingBagCollectionSharder,
get_module_to_default_sharders,
ManagedCollisionEmbeddingBagCollectionSharder,
ManagedCollisionEmbeddingCollectionSharder,
ParameterShardingGenerator,
QuantEmbeddingBagCollectionSharder,
QuantEmbeddingCollectionSharder,
Expand Down Expand Up @@ -52,7 +53,10 @@
)
from torchrec.modules.fp_embedding_modules import FeatureProcessedEmbeddingBagCollection
from torchrec.modules.fused_embedding_modules import FusedEmbeddingBagCollection
from torchrec.modules.mc_embedding_modules import ManagedCollisionEmbeddingBagCollection
from torchrec.modules.mc_embedding_modules import (
ManagedCollisionEmbeddingBagCollection,
ManagedCollisionEmbeddingCollection,
)
from torchrec.quant.embedding_modules import (
EmbeddingBagCollection as QuantEmbeddingBagCollection,
EmbeddingCollection as QuantEmbeddingCollection,
Expand Down Expand Up @@ -685,12 +689,12 @@ def test_str(self) -> None:
expected = """
module: ebc
param | sharding type | compute kernel | ranks
param | sharding type | compute kernel | ranks
-------- | ------------- | -------------- | ------
user_id | table_wise | dense | [0]
user_id | table_wise | dense | [0]
movie_id | row_wise | dense | [0, 1]
param | shard offsets | shard sizes | placement
param | shard offsets | shard sizes | placement
-------- | ------------- | ----------- | -------------
user_id | [0, 0] | [4096, 32] | rank:0/cuda:0
movie_id | [0, 0] | [2048, 32] | rank:0/cuda:0
Expand All @@ -710,6 +714,7 @@ def test_module_to_default_sharders(self) -> None:
QuantEmbeddingBagCollection,
QuantEmbeddingCollection,
ManagedCollisionEmbeddingBagCollection,
ManagedCollisionEmbeddingCollection,
],
)
self.assertIsInstance(
Expand Down Expand Up @@ -738,3 +743,8 @@ def test_module_to_default_sharders(self) -> None:
default_sharder_map[ManagedCollisionEmbeddingBagCollection],
ManagedCollisionEmbeddingBagCollectionSharder,
)

self.assertIsInstance(
default_sharder_map[ManagedCollisionEmbeddingCollection],
ManagedCollisionEmbeddingCollectionSharder,
)

0 comments on commit dd155ef

Please sign in to comment.