-
Notifications
You must be signed in to change notification settings - Fork 61
Temporary Fix for FP16 -> FP8 conversion failure on -0.0 #2387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yucai-intel
wants to merge
9
commits into
main
Choose a base branch
from
yucai/fp8/fix1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ac60ff0
Update CopyKernel.cpp
yucai-intel 3bb86ae
Update CopyKernel.cpp
yucai-intel d0d7327
method2
yucai-intel df180a7
Merge branch 'main' into yucai/fp8/fix1
yucai-intel cb52f93
format
yucai-intel 8f62152
Fix FP16 to FP32 conversion
CuiYifeng 42de29b
Add test cases
CuiYifeng 58f54b5
Simplify template
CuiYifeng ddf4e88
Refine fixing
CuiYifeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Owner(s): ["module: intel"] | ||
| import torch | ||
| from torch.testing._internal.common_device_type import ( | ||
| dtypes, | ||
| instantiate_device_type_tests, | ||
| ) | ||
| from torch.testing._internal.common_dtype import float8_types | ||
| from torch.testing._internal.common_utils import run_tests, TestCase | ||
|
|
||
| cpu_device = torch.device("cpu") | ||
| xpu_device = torch.device("xpu") | ||
|
|
||
|
|
||
| class TestSimpleConversion(TestCase): | ||
| def _compare_convert_with_cpu(self, src_cpu, dtype): | ||
| src_xpu = src_cpu.to(xpu_device) | ||
| dst_cpu = src_cpu.to(dtype) | ||
| dst_xpu = src_xpu.to(dtype) | ||
| self.assertEqual(dst_xpu.to(cpu_device), dst_cpu) | ||
|
|
||
| @dtypes(*float8_types()) | ||
| def test_half_zero(self, dtype): | ||
| pos_zero_fp16_cpu = torch.zeros((5, 6), dtype=torch.float16) | ||
| self._compare_convert_with_cpu(pos_zero_fp16_cpu, dtype) | ||
|
|
||
| neg_zero_fp16_cpu = torch.full((5, 6), -0.0, dtype=torch.float16) | ||
| self._compare_convert_with_cpu(neg_zero_fp16_cpu, dtype) | ||
|
|
||
| @dtypes(*float8_types()) | ||
| def test_half_nonzero(self, dtype): | ||
| x_fp16_cpu = torch.arange(-100.0, 101.0, dtype=torch.float16) | ||
| self._compare_convert_with_cpu(x_fp16_cpu, dtype) | ||
|
|
||
|
|
||
| instantiate_device_type_tests( | ||
| TestSimpleConversion, globals(), only_for="xpu", allow_xpu=True | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_tests() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.