-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support serialization of compound module
Summary: # context * to support compound module serialization such as fpEBC and fpPEA, we modified the serializer interface a little * the basic idea is that: a. if a compound module A consists of child module B and C, such that module B and C have their own serializer available. b. for serialization of module A, we can just capture it relation from B and C, and used it when deserialization c. specifically, during the deserialization, A's children will be passed in as a dict of (child_fqn => child_module) # design doc [**TorchRec Composable Serializer Design**](https://docs.google.com/document/d/1WUtmzdcqZmwLd4Do8g1fQRjChnRw0ZimyUrCNhxa4nA/edit#heading=h.ezrtdguw0lwq) # note * in order to apply this approach, it requires that module A's construction **takes in it's children as objects** * **DO NOT** create A's children in the A's construction # details * serialization schedule ``` comp.ebc does NOT require further serialization of its children comp.ebc.embedding_bags is skipped for further serialization comp.ebc.embedding_bags.t1 is skipped for further serialization comp.ebc.embedding_bags.t2 is skipped for further serialization comp.ebc.embedding_bags.t3 is skipped for further serialization comp.comp is resumed for serialization comp.comp Requires further serialization of its children comp.comp.ebc does NOT require further serialization of its children comp.comp.ebc.embedding_bags is skipped for further serialization comp.comp.ebc.embedding_bags.t1 is skipped for further serialization comp.comp.ebc.embedding_bags.t2 is skipped for further serialization comp.comp.ebc.embedding_bags.t3 is skipped for further serialization comp.comp.comp is resumed for serialization comp.comp.comp Requires further serialization of its children comp.comp.comp.ebc does NOT require further serialization of its children comp.comp.comp.ebc.embedding_bags is skipped for further serialization comp.comp.comp.ebc.embedding_bags.t1 is skipped for further serialization comp.comp.comp.ebc.embedding_bags.t2 is skipped for further serialization comp.comp.comp.ebc.embedding_bags.t3 is skipped for further serialization ``` * `parent_fqn`'s children ``` comp.comp.comp {'ebc': EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) )} None None ``` ``` comp.comp {'ebc': EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) ), 'comp': CompoundModule( (ebc): EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) ) )} None None ``` ``` comp {'ebc': EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) ), 'comp': CompoundModule( (ebc): EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) ) (comp): CompoundModule( (ebc): EmbeddingBagCollection( (embedding_bags): ModuleDict( (t1): EmbeddingBag(10, 4, mode='sum') (t2): EmbeddingBag(10, 4, mode='sum') (t3): EmbeddingBag(10, 4, mode='sum') ) ) ) )} None None ``` Differential Revision: D58221182
- Loading branch information
1 parent
744ba95
commit 11726d3
Showing
4 changed files
with
182 additions
and
21 deletions.
There are no files selected for viewing
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 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 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 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