Repository navigation
[xpu][fix]Relax fp16 grad tolerance for native_group_norm on XPU - #191601
Closed
ZhaoqiongZ wants to merge 1 commit into
Closed
ZhaoqiongZ wants to merge 1 commit into
ZhaoqiongZ wants to merge 1 commit into
Conversation
pytorch#190245 fixed missed upcasts in the CUDA native_group_norm_backward kernel/decomposition and replaced the previous `check_gradient: False` overrides with looser tolerances (`grad_atol=2e-3, grad_rtol=1e-3`). That PR left the CUDA override in place but removed the corresponding XPU override without adding anything back, leaving XPU on the default fp16 tolerance (`atol=1e-5, rtol=1e-3`) which is too tight for the residual 1-ULP rounding differences between the XPU aten backward kernel and the Inductor decomposition. Result: pytorch#185367 (`test_comprehensive_native_group_norm_xpu_float16`) has been disabled since May 2026. Root cause on the failing sample (input=(1,6,3), groups=2, eps=0.5, fp16): d_input: eager vs ref-fp32: max_abs=9.77e-04 comp vs ref-fp32: max_abs=9.77e-04 comp vs eager : max_abs=9.77e-04 (>> default atol=1e-5) Both eager and compiled backward stay within fp16 quantization of an fp32 reference, but they round to different fp16 values at some indices. The XPU aten kernel already accumulates in fp32 (`T_ACC`); the residual difference comes from the aten kernel executing as several TensorIterator launches vs Inductor materializing one fused fp32 graph. This is intrinsic fp16 rounding, not a correctness bug on either side, and matches the situation upstream addressed on CUDA in pytorch#190245. Align XPU with the CUDA precedent in the same PR by adding the same `(native_group_norm, f16)` override to `inductor_override_kwargs['xpu']`. ## Test plan Against nightly wheel `torch==2.14.0.dev20260728+xpu` on Intel Data Center GPU Max 1100: ``` python -m pytest test/inductor/test_torchinductor_opinfo.py -v \ -k test_comprehensive_native_group_norm_xpu --timeout=600 # native_group_norm_xpu_float16 PASSED # native_group_norm_xpu_float32 PASSED # native_group_norm_xpu_float64 PASSED # 3 passed, 7450 deselected ``` Fixes pytorch#185367 Note: authored with AI assistance.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/191601
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit bba7bce with merge base 2da8437 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR relaxes fp16 gradient-check tolerances for native_group_norm on XPU in Inductor OpInfo comprehensive tests, aligning XPU behavior with the existing CUDA precedent to avoid false failures from expected fp16 rounding differences between eager and Inductor decomposition paths.
Changes:
- Add an XPU-specific
("native_group_norm", f16)override withgrad_atol=2e-3andgrad_rtol=1e-3. - Document the rationale in-line, referencing the CUDA tolerance adjustment in #190245.
ZhaoqiongZ
marked this pull request as ready for review
July 30, 2026 08:29
etaf
approved these changes
Jul 30, 2026
guangyey
approved these changes
Jul 30, 2026
jansel
approved these changes
Jul 31, 2026
Collaborator
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
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.
Motivation
#190245 fixed missed upcasts in the CUDA
native_group_norm_backwardkernel/decomposition and replaced the previouscheck_gradient: Falseoverrides with looser tolerances (grad_atol=2e-3, grad_rtol=1e-3). That PR left the CUDA override in place but removed the corresponding XPU override without adding anything back, leaving XPU on the default fp16 tolerance (atol=1e-5, rtol=1e-3) which is too tight for the residual 1-ULP rounding differences between the XPU aten backward kernel and the Inductor decomposition. Result: #185367 (test_comprehensive_native_group_norm_xpu_float16) has been disabled since May 2026.Root cause on the failing sample
Sample:
input=(1,6,3), groups=2, eps=0.5, fp16Both eager and compiled backward stay within fp16 quantization of an fp32 reference, but they round to different fp16 values at some indices. The XPU aten kernel already accumulates in fp32 (
T_ACC); the residual difference comes from the aten kernel executing as several TensorIterator launches vs Inductor materializing one fused fp32 graph. This is intrinsic fp16 rounding, not a correctness bug on either side, and matches the situation upstream addressed on CUDA in #190245.Fix
Align XPU with the CUDA precedent from the same PR by adding the same
(native_group_norm, f16)override toinductor_override_kwargs["xpu"].Test plan
Against nightly wheel
torch==2.14.0.dev20260728+xpuon Intel Data Center GPU Max 1100:Fixes #185367
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @guangyey
Note: authored with AI assistance.