Repository navigation
native_group_norm_backward: Fix precision errors - #190245
benjaminglass1 wants to merge 12 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190245
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 473c5f7 with merge base ae5ff14 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes #180740 ghstack-source-id: 9f64c44 Pull-Request: #190245
|
@claude review these changes |
|
Claude finished @jansel's task in 4m 20s —— View job PR Review: #190245One sentence summary: The refactor is correct and the precision fixes are well-targeted; I only found minor wording nits, so this looks good to merge. Full review detailsSummaryFixes missing accumulator upcasts in the 1D group-norm backward CUDA kernel and the Code Quality
Testing
Notes (verified, no action needed)
RecommendationApprove — the two items above are comment-only clarity fixes and don't block. The removed XFAIL/skip entries are appropriate since the fixes make those OpInfo/decomp tests pass, giving adequate regression coverage. |
|
This looks good to me, I think the suggested comment change from janselbot's review is valid, and would be worth quickly doing, but otherwise nothing else I can see to mention. |
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes #180740 ghstack-source-id: 25bd6d3 Pull-Request: #190245
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes #180740 ghstack-source-id: 25bd6d3 Pull-Request: #190245
[ghstack-poisoned]
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes #180740 ghstack-source-id: 776457a Pull-Request: #190245
|
@pytorchbot merge |
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 |
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes pytorch#180740 Pull Request resolved: pytorch#190245 Approved by: https://github.com/slayton58
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests. Closes pytorch#180740 Pull Request resolved: pytorch#190245 Approved by: https://github.com/slayton58
…1601) ## Motivation #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: #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, 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 #190245. ## Fix Align XPU with the CUDA precedent from 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 #185367 _Note: authored with AI assistance._ Pull Request resolved: #191601 Approved by: https://github.com/etaf, https://github.com/guangyey, https://github.com/jansel
Stack from ghstack (oldest at bottom):
Fixes missed upcasts in the CUDA kernel and decomposition for native_group_norm_backward. Re-works infinitely_differentiable_native_group_norm_backward to use native_group_norm_backward where possible (ensures we actually use the decomposition in cases where Inductor can't prove the other two gradients are unused). Fixes a broken Inductor benchmark in the pipeline, as well as three XFAILed tests.
Closes #180740
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo