Fix failure on DeBERTa(base/v2/sew_d) fp16 training with ONNX Runtime #18585
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
It was reported in optimum huggingface/optimum#305 that the mixed-precision training on DeBERTa with optimum.onnxruntime.ORTTrainer is broken.
After investigation, the break comes from mismatched inputs dtype for some Matmul nodes. In #18272, some sqrt results are cast to fp32, and they need to be re-casted to fp16 before Matmul ops, and this PR is supposed to correct the dtype.
Besides, this PR also fix the tracing of DeBERTa which haven't been fixed in #18272
Fixes #huggingface/optimum#305
Fixes #18199
Who can review?
@michaelbenayoun @LysandreJik @sgugger