Gradient Overflow & Prediction FP16 Input FP32
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9k
- Forks
- 1.5k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
I have tried to use APEX's AMP O1 I have the following problems:
- My network input is FP32 but the prediction is FP16 which results in PyTorch errors since the types are not the same
- If I try to fix 1. by casting the prediction to FP32 via tensor.float() I start running into Gradient Overflows. They happen nearly continuously, I have 1 - 2 batches that do not overflow here and there but very rarely. Also, it leads to non-finite values (inf,-inf,nan) in my predictions.
If I change to us O2 I have yet another mixed FP32 FP16 operation error in my code. The documentation does not help at all for this, so my question is, can I tell AMP to keep a certain tensor to FP32 or keep all the tensors in the loss to FP32?
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 with the reported O1/O2 mixed-precision behavior and the linked APEX advanced documentation section on forcing particular layers or functions to a desired type. Reproduce the FP16 prediction, FP32 cast, and gradient-overflow symptoms if the original network is available; done means documenting or correcting the supported way to keep the relevant tensor or loss computation in FP32.
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
- 30/100