Skip to content

Commit

Permalink
apply fp16 autocast only to floating point values
Browse files Browse the repository at this point in the history
  • Loading branch information
tohtana committed Oct 11, 2024
1 parent adec991 commit 5c4b97f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deepspeed/runtime/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ def _cast_inputs_half(self, inputs):
for k, v in inputs.items():
new_inputs[k] = self._cast_inputs_half(v)
return new_inputs
elif hasattr(inputs, 'half'):
elif hasattr(inputs, 'half') and inputs.is_floating_point():
return inputs.half()
else:
return inputs
Expand Down

0 comments on commit 5c4b97f

Please sign in to comment.