f-dangel / f-dangel/backpack

Name collision with .output in real world modules

Open
#330 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
617
Forks
57
PR merge metrics
No merged PRs in 30d

Description

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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.