feat: support softmax operator on metax#1347
Open
LindseyMei wants to merge 1 commit into
Open
Conversation
Add MetaX backend for softmax operator, reusing cuda/kernel.cuh with hccub/cub block reduce headers. Tested on MetaX C500: all shapes/axes/dtypes/inplace modes pass. Signed-off-by: LindseyMei <648816901@qq.com>
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.
Summary
Add MetaX backend support for the
softmaxoperator, following the same pattern ascausal_softmax/metaxand reusingsoftmax/cuda/kernel.cuh.Changes
src/infiniop/ops/softmax/metax/softmax_metax.h: MetaX descriptor declaration.src/infiniop/ops/softmax/metax/softmax_metax.maca: MetaX kernel launch logic, supporting F16/BF16/F32 with block/warp softmax paths.src/infiniop/ops/softmax/operator.cc: Register MetaX backend in CREATE/GET/CALCULATE/DESTROY switches.Validation
Tested on MetaX C500 (MACA 3.3.0.15):
Result:
Test passed!covering shapes(4,4),(12,16,512,512),(1,16,512,512)across all axes, F16/F32, and inplace/out-of-place modes.Performance
Because the built-in
test/infiniop/softmax.py --profilereports implausibly small timings for softmax (~0.007 ms for 50M elements), throughput was measured with standalone scripts that explicitly calltorch.cuda.synchronize()around each iteration.Softmax along the last axis (
axis=1) on 2-D tensors:Notes
cuda/kernel.cuhor nvidia backend.hccub/block/block_reduce.cuhfor MACA and<cub/block/block_reduce.cuh>for MC path.clang-format --dry-run --Werror.