Repository navigation
Conversation
#202533 moved CPU vector_norm and _powsum with ord 0, 1 and 2 to a new cascade_powsum_kernel dispatched under a new kernel tag, cascade_powsum_cpu. Selective (mobile) builds keep only the dtypes their traced model lists name for each tag, and lists traced before #202533 have norm_cpu and powsum_cpu but not the new tag, so those builds now fail with "dtype 'Float' not selected for kernel tag cascade_powsum_cpu". Dispatch the cascade kernel under the tags of the kernels it replaces, and fall back to the old kernel when the build did not select the input dtype for that tag (e.g. a half input with a float output, which the old code reduced without a tagged dispatch). Builds traced before #202533 then behave as before or use the new kernel; full builds are unchanged. Regenerating every traced dtype list instead would leave any app not re-traced broken at runtime. Test Plan: Compiled SumKernel.cpp before and after this change, normally and with -DTEMPLATE_SELECTIVE_BUILD and a selected_mobile_ops.h selecting only Float for norm_cpu, powsum_cpu and sum_cpu. With the selection, the old object has no float cascade_powsum kernels (the dispatch throws), the new one has them: ``` nm -C sel.o | grep -o 'cascade_sum<[^(]*' # before: IdentityMap, float, float # after: AbsMap, IdentityMap, NonZeroMap, SquareMap (float, float) lintrunner -a aten/src/ATen/native/cpu/SumKernel.cpp ``` Authored with an AI assistant.
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (4): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205834
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 3b4a687 with merge base 944193e ( 🟡 GREEN LIGHT - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Automated review of 3b4a687: nothing blocking; ready for human review.
The PR runs the CPU cascade vector_norm/_powsum kernel under the old norm_cpu/powsum_cpu tags, falling back to the old kernel when a selective build did not select the dtype. This fixes builds traced before # 202533 but not builds traced while # 202533 was in. Recommendation: Needs Discussion. Whether those builds break depends on an open question for maintainers (was any production list traced while # 202533 was in?), so no defect was named that must be fixed unconditionally.
⚪ 4 non-blocking findings
Builds traced after # 202533 and before this PR now fail at runtime. With # 202533 in, a tracer build running float/double vector_norm or _powsum with ord 0, 1 or 2 records cascade_powsum_cpu$Float and never reaches the norm_cpu/powsum_cpu dispatches, so norm_cpu$Float is missing unless another ord or a complex input was used. With this PR, should_include_kernel_dtype("norm_cpu", Float) returns false, and the fallback at ReduceOpsKernel.cpp:221 throws dtype 'Float' not selected for kernel tag norm_cpu. The same happens for Double, and for Half/BFloat16 reduced to a one-element result of the same dtype. Those apps work today and would break unless re-traced, which is the outcome the PR gives as its reason not to regenerate lists. Fix: also take the cascade path when should_include_kernel_dtype("cascade_powsum_cpu", in) is true. That needs a third AT_DISPATCH under that literal, which only adds a switch because the instantiations are shared. Or state in the PR that no list was traced or shipped while # 202533 was in. Must land before merge if such lists exist.
Low confidence, non-blocking: pre-# 202533 lists can still fail inside the cascade kernel on fill_. For outputs with more than one element, cascade_sum (SumKernel.cpp:707) calls iter.output_base().fill_(out_t(0)), which goes through the dispatcher and the "fill_cpu" dtype dispatch. The old binary_kernel_reduce path never calls fill_. So a list with norm_cpu$Float but not aten::fill_.Scalar or fill_cpu$Float now passes this check and then fails. Most real lists probably have fill_, but the claim that such builds "behave as before or use the new kernel" is not guaranteed, and a test plan that only compiles and inspects symbols would not catch it. Related, not new here: cpu_powsum_in_float (LinearAlgebra.cpp:2894-2910) still sends Half/BFloat16 results with more than one element through result.copy_ whatever the build selected.
Non-blocking: two comments now misstate when the kernel returns false or falls back. SumKernel.h:15-22 still says cascade_powsum_kernel returns false only for unsupported p or dtypes. It now also returns false when the build did not select in for the tag, so callers must keep the fallback even for supported p and dtypes. The comment here says an unselected dtype "falls back to the old kernel instead of throwing". That only holds for Half/BFloat16 input with Float output, which uses the untagged branch at ReduceOpsKernel.cpp:213-218 / :448-451. Every other case dispatches under the same tag on the same dtype and still throws.
Non-blocking: the tag strings are duplicated and must be kept in sync by hand (line 771 vs 777 and 781), and also with the literals at ReduceOpsKernel.cpp:221 and :454. If they drift, the check passes for a dtype the dispatch did not select, and the call throws instead of falling back. Fix: move the should_include_kernel_dtype check into each if (is_norm) branch next to its AT_DISPATCH, with one named constexpr string per branch. The restructure for the cascade_powsum_cpu tag finding is a natural place to do this.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot merge |
|
@pytorchbot merge |
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
|
@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 |
#202533 moved CPU vector_norm and _powsum with ord 0, 1 and 2 to a new cascade_powsum_kernel dispatched under a new kernel tag, cascade_powsum_cpu. Selective (mobile) builds keep only the dtypes their traced model lists name for each tag, and lists traced before #202533 have norm_cpu and powsum_cpu but not the new tag, so those builds now fail with "dtype 'Float' not selected for kernel tag cascade_powsum_cpu".
Dispatch the cascade kernel under the tags of the kernels it replaces, and fall back to the old kernel when the build did not select the input dtype for that tag (e.g. a half input with a float output, which the old code reduced without a tagged dispatch). Builds traced before #202533 then behave as before or use the new kernel; full builds are unchanged. Regenerating every traced dtype list instead would leave any app not re-traced broken at runtime.
Test Plan:
Compiled SumKernel.cpp before and after this change, normally and with -DTEMPLATE_SELECTIVE_BUILD and a selected_mobile_ops.h selecting only Float for norm_cpu, powsum_cpu and sum_cpu. With the selection, the old object has no float cascade_powsum kernels (the dispatch throws), the new one has them:
Authored with an AI assistant.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01