fix(mul): handle broadcasted operand indexing - #935
Draft
voltjia wants to merge 1 commit into
Draft
Conversation
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
Muloperand metadata to the output rank and use zero strides for broadcast dimensions.Motivation
Mulpreviously treated every contiguous operand as flat over the output. For an output such as[1, 151936], a contiguous[1, 1]operand was indexed beyond element zero instead of being broadcast. This could read out of bounds and surface later as non-finite results or an asynchronous device error.Type of Change
feat- new feature / new operator / new platformfix- bug fixperf- performance improvement (no behavioral change)refactor- code restructuring without behavior changetest- adding or fixing tests onlydocs- documentation onlybuild/ci- build system or CI configurationchore- tooling, formatting, or other non-code changesPlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Validated exact public head
b170ae2c1d85b6f51de332c916448729fa379fe5on 8x A100 80 GB withaccelerator-dev/nvidia:latestand InfiniRT0cdbb16967e15f2e055dea1ec9641617bf3b6cf6:All validation checkouts remained on the exact head with no tracked changes.
Test Results on Supported Platforms
tests/test_mul.py159/159; direct BF16 stress 500/500.Mulimplementation.Mulimplementation.Mulimplementation consumes this metadata.Mulimplementation.aclnnMulconsumes the original tensor descriptors rather than the base indexing metadata.Benchmark / Performance Impact
N/A. This is a correctness fix; kernel arithmetic and launch configuration are unchanged.
Notes for Reviewers
The key invariant is that a broadcasted operand must not take the contiguous fast path. Its logical shape is expanded to the output rank, and zero strides select the same source element along broadcast dimensions.
The first Ascend and Cambricon CI attempts were cancelled by self-hosted runner network failures (
127.0.0.1:7897proxy connection refused / artifact uploadECONNRESET) before compilation or tests. They are infrastructure failures, not failures in this patch; rerun is pending workflow availability.