Skip to content

[AutoDeploy] rms norm pattern matching - #8

Closed
suyoggupta wants to merge 39 commits into
feat/ad_coverage_week3from
user/sg/rms-norm-matcher
Closed

[AutoDeploy] rms norm pattern matching#8
suyoggupta wants to merge 39 commits into
feat/ad_coverage_week3from
user/sg/rms-norm-matcher

Conversation

@suyoggupta

@suyoggupta suyoggupta commented May 17, 2025

Copy link
Copy Markdown

This PR introduces RMSNorm support by adding a graph transformation that matches RMSNorm patterns and replaces them with optimized FlashInfer or Triton custom ops. It also integrates the new pattern matcher into the transformation pipeline and adds a unit test.

Add match_rms_norm_with_pm transform and register it in the main pipeline
Implement custom operators for FlashInfer and Triton RMSNorm
Introduce a new unit test for end-to-end validation

Test Coverage

Unit tests for the rms norm transformation

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--disable-fail-fast --skip-test --stage-list "A10-1, xxx" --gpu-type "A30, H100_PCIe" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-[Post-Merge]-1, xxx"]

Launch build/test pipelines. All previously running jobs will be killed.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests. Will also run L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-[Post-Merge]-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-[Post-Merge]-1, xxx".

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Fridah-nv added 30 commits May 14, 2025 17:44
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…alculation node

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…d unit test case

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…ope + minor updates

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…ope_with_qk_interleaving, update unit test

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…pose unsqueeze_dim and support match_rope_layout, add unit tests

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…cuda graph capture

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Ubuntu <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…mapping to flashinfer op

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…ocstring and test

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Fridah-nv <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
…tcher

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Ubuntu <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Ubuntu <201670829+Fridah-nv@users.noreply.github.com>
…tcher

Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Fridah-nv and others added 7 commits May 16, 2025 15:30
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Ubuntu <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Ubuntu <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Suyog Gupta <41447211+suyoggupta@users.noreply.github.com>
Signed-off-by: Frida Hou <201670829+Fridah-nv@users.noreply.github.com>
Signed-off-by: Suyog Gupta <41447211+suyoggupta@users.noreply.github.com>
@suyoggupta
suyoggupta requested a review from Copilot May 17, 2025 00:43
@suyoggupta
suyoggupta changed the base branch from main to user/fridah/pattern-matcher May 17, 2025 00:44

This comment was marked as outdated.

Signed-off-by: Suyog Gupta <41447211+suyoggupta@users.noreply.github.com>
@suyoggupta
suyoggupta requested a review from Copilot May 17, 2025 00:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces RMSNorm support by adding a graph transformation that matches RMSNorm patterns and replaces them with optimized FlashInfer or Triton custom ops. It also integrates the new pattern matcher into the transformation pipeline and adds a unit test.

  • Add match_rms_norm_with_pm transform and register it in the main pipeline
  • Implement custom operators for FlashInfer and Triton RMSNorm
  • Introduce a new unit test for end-to-end validation

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unittest/_torch/auto_deploy/unit/singlegpu/transformations/library/test_rms_norm.py Add unit tests for RMSNorm pattern matching and execution
tensorrt_llm/_torch/auto_deploy/utils/pattern_matcher_utils.py New utilities for FX-based pattern matchers with op-ignore support
tensorrt_llm/_torch/auto_deploy/transformations/transform.py Invoke match_rms_norm_with_pm in the transform pipeline
tensorrt_llm/_torch/auto_deploy/transformations/library/rms_norm.py Implement RMSNorm pattern registration and replacement logic
tensorrt_llm/_torch/auto_deploy/transformations/library/init.py Export the new RMSNorm transform
tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py Define FlashInfer and Triton custom RMSNorm operators
tensorrt_llm/_torch/auto_deploy/custom_ops/init.py Export the new RMSNorm custom ops
Comments suppressed due to low confidence (2)

tests/unittest/_torch/auto_deploy/unit/singlegpu/transformations/library/test_rms_norm.py:44

  • [nitpick] Rename the parameter variant to something more descriptive like backend to clarify its purpose in selecting the RMSNorm implementation.
@pytest.mark.parametrize("variant", ["flashinfer", "triton"])

tests/unittest/_torch/auto_deploy/unit/singlegpu/transformations/library/test_rms_norm.py:43

  • The tests currently only cover float16 inputs. Consider parameterizing over input dtypes (e.g., bfloat16 and float32) to validate pattern matching and custom ops across all supported precisions.
@pytest.mark.parametrize("eps", [1e-2, 1e-6])

patterns=patterns,
dummy_args=dummy_args(input_dtype, weight_dtype),
op_ignore_types={},
scalar_workaround={"eps": 1e-6},

Copilot AI May 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current pattern registration hard-codes eps=1e-6 and does not ignore variations in eps; as a result, patterns with different eps values (e.g., 1e-2) won't match. Consider passing exclusive_arg_names=('eps',) to register_pattern so the eps argument is treated as a wildcard.

Suggested change
scalar_workaround={"eps": 1e-6},
exclusive_arg_names=('eps',),

Copilot uses AI. Check for mistakes.
lambda num_p_og: num_p_og,
dynamic_shapes={0: Dim("batch_size", max=8)},
)
print(gm_transformed.graph)

Copilot AI May 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or replace this print statement with a logging call (e.g., logger.debug) to avoid polluting test output.

Suggested change
print(gm_transformed.graph)
logger.debug(gm_transformed.graph)

Copilot uses AI. Check for mistakes.
Signed-off-by: Suyog Gupta <41447211+suyoggupta@users.noreply.github.com>
@suyoggupta
suyoggupta requested a review from Fridah-nv May 17, 2025 01:05
@Fridah-nv
Fridah-nv force-pushed the user/fridah/pattern-matcher branch 2 times, most recently from a01fef5 to 27795ad Compare June 4, 2025 23:47
Base automatically changed from user/fridah/pattern-matcher to feat/ad_coverage_week3 June 5, 2025 00:21
@lucaslie

Copy link
Copy Markdown

We should probably wait until NVIDIA#5106 gets merged before we continue working on this one

@suyoggupta

Copy link
Copy Markdown
Author

subsumed in #58

@suyoggupta suyoggupta closed this Jun 13, 2025
MrGeva pushed a commit that referenced this pull request Oct 26, 2025
NVIDIA#8344)

Signed-off-by: ziyixiong-nv <219238287+ziyixiong-nv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants