Skip to content

Name collision with .output in real world modules #330

@Skylion007

Description

@Skylion007

Currently, hooks store values in module.output this causes an issue when using any model that uses .output to store an nn.Module attribute. It's a very generic name that can collide with a variety of modules. As such, I cannot run backpack-for-pytorch on huggingface bert models. It would be better if the name was something more specific, even just backpack_for_pytorch_output or even backpack_output to prevent collisions with attributes of the module.

Creates an error similar:

/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in __setattr__(self, name, value)
   1982             elif modules is not None and name in modules:
   1983                 if value is not None:
-> 1984                     raise TypeError(
   1985                         f"cannot assign '{torch.typename(value)}' as child module '{name}' "
   1986                         "(torch.nn.Module or None expected)"

TypeError: cannot assign 'torch.FloatTensor' as child module 'output' (torch.nn.Module or None expected)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions