Error with custom normalization layer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.5k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
Hi, thank you for your great work.
I have a question regarding custom normalization layer.
Since all of the modules which is not
'isinstance(module, torch.nn.modules.batchnorm._BatchNorm) and module.affine is True'
will be converted to fp16, custom normalization layer such as batch-instance-normalization(https://github.com/hyeonseob-nam/Batch-Instance-Normalization/blob/master/models/batchinstancenorm.py) throws an 'RuntimeError: expected scalar type Half but found Float'.
I have tried converting input into float only in custom norm layer to resolve the error above. However, it resulted in more GPU memory usage than usual fp32 training.
What is the best way to unconvert those module after amp.initialize?
Also, as I debugged batchnorm layer, I have found that input tensor to batchnorm is half type on opt_level 'O1'. Does 'keep_batchnorm_fp32' means only keeping weight of batchnorm in fp32?
Thank you for your help.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the amp.initialize entry point and inspect the module-conversion logic described in the issue, then reproduce the error with the linked batchinstancenorm.py custom layer. Check the O1 and keep_batchnorm_fp32 paths, including the observed BatchNorm input type. Done means the custom normalization behavior and BatchNorm precision semantics are clarified or corrected with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100