Added
A team is fine-tuning an image-and-caption model for product search. During training, the contrastive loss sometimes becomes NaN shortly after mixed-precision training starts; the image and text encoders otherwise produce finite embeddings. The GPU budget is fixed, and restarting with full precision would make the planned experiment exceed its deadline. The training code computes cosine similarities, scales the similarity matrix by a learned temperature, and then applies a softmax-based contrastive objective. What is the best next action to stabilize training while preserving the current hardware plan?
Keeping the similarity logits, temperature scaling, and loss computation in float32 is a targeted stability measure: reduced-precision encoder operations can remain enabled, while sensitive softmax and scaling arithmetic avoid overflow or underflow. Increasing the learning rate does not address numerical range and can worsen instability. Removing normalization changes the intended cosine-based objective and can make logit magnitudes less controlled. Mean squared error is not a drop-in replacement for a contrastive objective and would discard its batch-level negative comparisons.