torch.func.stack_module_state
- torch.func.stack_module_state(models) → params, buffers
Prepares a list of torch.nn.Modules for ensembling with
vmap().Given a list of
Mof the same class, returns two dictionaries that stack all of their parameters and buffers together, indexed by name. The stacked parameters are optimizable (i.e. they are new leaf nodes in the autograd history that are unrelated to the original parameters and can be passed directly to an optimizer).