Repository navigation
Support double in optimized log_softmax - #23686
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23686
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f23eb3b with merge base 6cc8edf ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: ops & kernels" |
JakeStevens
left a comment
There was a problem hiding this comment.
a few nits:
(1) can you add test_dtype_noncontiguous_dim<double, ScalarType::Double>() to NonContiguous in kernels/test/op_log_softmax_test.cpp so we test that pathway too?
(2) The non-last-dim tiling hardcodes vec_logsoftmax_chunk_size_and_num_chunks<float, 64 * 1024> . Pre-existing, but for double the byte budget doubles; templating on IN_T would match ATen's own caller. The new test above would cover either choice.
(3) Please update fbcode/executorch/kernels/test/supported_features_summary.md to reflect the yaml changes
The optimized _log_softmax.out kernel rejected float64 inputs with InvalidArgument, while the portable kernel supports them. The ATen vectorized helpers it uses work for double, so run it through the same same-dtype path as Half and BFloat16, and stop skipping the double tests for the optimized kernels.
Run the non-contiguous log_softmax test for double when the kernel supports it, size the non-last-dim chunks by the input element type as ATen's caller does, and mark double as supported for the optimized kernel in the supported features summary.
7ec4128 to
f23eb3b
Compare
|
Thanks! Done in f23eb3b, on top of a rebase onto main (6cc8edf):
Locally: |
Summary
The optimized
_log_softmax.outkernel only handled Float, Half and BFloat16, with aTODO: support Double as well. A float64log_softmaxfails at runtime wherever the optimized kernels are linked, including the Python runtime, while the same program runs with the portable kernels:The ATen vectorized helpers the kernel calls (
serial_vec_log_softmax_lastdim_range,serial_vec_logsoftmax_range) support double, so this adds a Double case that goes through the same same-dtype path as Half and BFloat16. It also removes theop_log_softmax: dtype_double: falseentry fromkernels/optimized/test/supported_features_def.yaml, so the existing double tests run for the optimized kernels too.Test plan
I built
optimized_kernels_testwith CMake (EXECUTORCH_BUILD_TESTS=ON,EXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON) on Linux x86_64 (WSL2).With the yaml entry removed but without the kernel change,
AllDtypesSupported,TestWithLargeNumberandDoubleCasefail. With this change, all 13OpLogSoftmaxOutTesttests pass (4 of them were skipped before), and the fulloptimized_kernels_testrun passes (1657 tests).clang-format18.1.3 reports no changes.The repro above was run against executorch 1.5.1;
op_log_softmax.cppis the same on main.This PR was authored with AI assistance (Claude Code).
cc @larryliu0820 @manuelcandales @JakeStevens @nil-is-all