fix(rms_norm): support optional weight - #916
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
rms_normto receive an optionalweightacross the public C++, Python, and legacy C wrappers.weight=Nonein CPU, shared CUDA, and Cambricon native slot 0 by skipping the affine multiplication.weight=Nonebefore dereferencing it.Motivation
vLLM v0.26.0 exposes
_C::rms_norm(Tensor! result, Tensor input, Tensor? weight, float epsilon) -> (). InfiniOps previously required a concrete weight tensor, preventing normalization without the affine multiply.Upstream:
Type of Change
featfixperfrefactortestdocsbuild/cichorePlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Test Results on Supported Platforms
rms_norm: CPU cases passed; two stream-only cases skipped as expectedrms_norm: CPU+NVIDIA80 passed, 2 skipped; CUDA weighted/None and non-default-stream cases passedOperator<RmsNorm>implementationFocused validation
The two focused skips are the CPU variants of the accelerator-stream tests.
Fresh codegen preserved the legacy C raw descriptor/data pointer signatures. Both descriptor and call paths map
weight == nullptrto an empty optional before any dereference.Benchmark / Performance Impact
N/A. The weighted path keeps the existing kernels; the unweighted path avoids the weight read and multiply.
Notes for Reviewers
tests/test_rms_norm.py; no per-provider test module was added.weight=None.Nonewithout allocating a unit tensor or falling back.