You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gluon can have any hierarchy of Blocks where a top-level Block is not a HybridBlock, and lower-level blocks are HybridBlocks. These HybridBlocks can be dispersed throughout the model architecture. Users can optimize the parts of their model that support it by calling hybridize on the top level block to trigger a recursive call throughout all child blocks. But there is currently no way to export all HybridBlocks without going through and manually calling export on each one. Further, theres no way to reload those exported symbol files back without changing the model design and swapping those HybridBlocks for SymbolBlocks and than one-by-one calling imports to reload.
I would like to ask for suggestions from the community and have an active discussion on the different ways to address this problem. To kick things off, here is a proposal to start the discussion around:
With these two functions, we can recursively export each hybrid block and then reload the symbols. Obviously the code is not complete or even functional (_cached_graph is actual a tuple of symbols and sym.var inputs). But should serve as a point of reference.
Items on v1.x
Since a Block's children are stored in a dictionary, need to save/restore their unique names
Since parameters are mapped to their block's name, need to synchronize names after reloading model architecture to match save params
Items on master
Since parameters have a UUID, need to save/restore mapping of a Block's params to UUID
General Approach
Recursively create a dictionary structure of blocks mimicking the model architecture
Be able to uniquely identify the block in the model
For HybridBlocks, save/restore the cached graph (symbol + inputs) and in/out formats
Save the model architecture dictionary & parameters
Restore the model architecture with unique identifiers to synchronize with parameter naming/IDs
Description
Gluon can have any hierarchy of Blocks where a top-level Block is not a HybridBlock, and lower-level blocks are HybridBlocks. These HybridBlocks can be dispersed throughout the model architecture. Users can optimize the parts of their model that support it by calling
hybridizeon the top level block to trigger a recursive call throughout all child blocks. But there is currently no way to export all HybridBlocks without going through and manually callingexporton each one. Further, theres no way to reload those exported symbol files back without changing the model design and swapping those HybridBlocks for SymbolBlocks and than one-by-one callingimportsto reload.I would like to ask for suggestions from the community and have an active discussion on the different ways to address this problem. To kick things off, here is a proposal to start the discussion around:
With these two functions, we can recursively export each hybrid block and then reload the symbols. Obviously the code is not complete or even functional (
_cached_graphis actual a tuple of symbols and sym.var inputs). But should serve as a point of reference.Items on v1.x
Items on master
General Approach