pytorch / torchtitan

A native PyTorch Library for large model training
BSD 3-Clause "New" or "Revised" License
1.28k stars 115 forks source link

Use general way to access and update submodules #381

Closed kwen2501 closed 4 weeks ago

kwen2501 commented 4 weeks ago

Stack from ghstack (oldest at bottom):

This PR fixes the issue mentioned https://github.com/pytorch/pytorch/pull/126653#issuecomment-2130504712: "Module object has no attributed items."

The reason is, a split ModuleDict is no longer a ModuleDict.

It would be more generally applicable if we use named_children() and register_module() to access and update submodules.