[upstream #3137] [upstream_ut] RuntimeError: expected scalar type Half but found Float#24
Draft
Stonepia wants to merge 1 commit into
Draft
[upstream #3137] [upstream_ut] RuntimeError: expected scalar type Half but found Float#24Stonepia wants to merge 1 commit into
Stonepia wants to merge 1 commit into
Conversation
[upstream pytorch#3137] [upstream_ut] RuntimeError: expected scalar type Half but found Float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[upstream pytorch#3137] [upstream_ut] RuntimeError: expected scalar type Half but found Float
Fixes https://github.com/intel-sandbox/torch-xpu-ops-exp/issues/270
Root Cause: torch.is_autocast_enabled() at transformer.py:865 (and :490) checks only the default device type (cuda) for autocast. When XPU autocast is active, this returns False, so the fastpath is not disabled. The fused _transformer_encoder_layer_fwd then receives fp16 src (cast by autocast) alongside fp32 weights, causing the dtype mismatch.
Failed Tests:
test_transformers_xpu.py::TestTransformersXPU::test_transformerencoder_fastpath_use_torchscript_False_enable_nested_tensor_True_use_autocast_True_d_model_12_xputest_transformers_xpu.py::TestTransformersXPU::test_transformerencoder_fastpath_use_torchscript_False_enable_nested_tensor_False_use_autocast_True_d_model_256_xputest_transformers_xpu.py::TestTransformersXPU::test_transformerencoder_fastpath_use_torchscript_False_enable_nested_tensor_False_use_autocast_True_d_model_12_xputest_transformers_xpu.py::TestTransformersXPU::test_transformerencoder_fastpath_use_torchscript_False_enable_nested_tensor_True_use_autocast_True_d_model_256_xpuDiff stat: