Skip to content

Conversation

@dmklee
Copy link

@dmklee dmklee commented Sep 11, 2023

The assertion checks in SequentialModule.add_module assume that the module is
being added to the end of the sequence. However, it calls torch.nn.Module.add_module
which allows for overwriting existing modules by name. So, if one tries to overwrite an
existing module by name, an assertion error is raised. I modified the assertion checks
so that modules can be overwritten so long as they have the correct in_type and out_type
according to the modules before and after them in the sequence.

I encountered this issue when trying to call torch.nn.SyncBatchNorm.convert_sync_batchnorm
on a SequentialModule. With this change, you can sync InnerBatchNorm's across machines during
training since they use torch.nn.BatchNormXd under the hood.

Signed-off-by: David Klee <klee.d@northeastern.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant