Skip to content

chore: update the docstring for llama2 rmsnorm automatic plugin example #3512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion examples/dynamo/llama2_flashinfer_rmsnorm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
"""
.._llama2_flashinfer_rmsnorm:

Automatically generate a TensorRT Plugin for RMSNorm module and apply it in Llama2
===================================================================

This example showcases how to optimize inference for a LLaMA2 model by replacing its RMSNorm layers with FlashInfer's high-performance implementation. It demonstrates the use of Torch-TensorRT's automatic plugin feature, which dynamically generates and integrates custom TensorRT plugins during compilation.

Key features:
- Leverages automatic plugin registration for FlashInfer RMSNorm ops.
- Applies a custom TorchDynamo lowering pass to replace standard RMSNorm ops.
- Compiles the modified model using Torch-TensorRT's Dynamo path.
- Benchmarks inference performance with and without FlashInfer RMSNorm.

This example illustrates advanced extensibility in Torch-TensorRT through automatic plugin generation and operator lowering customization.
"""

from typing import Callable, Optional, Sequence, Union

import flashinfer
Expand Down Expand Up @@ -86,7 +103,7 @@ def replace_rmsnorm(
args=(node.args[0], 0),
)
b.meta["tensor_meta"] = TensorMetadata(
shape=torch.Size([]),
shape=torch.Size([1]),
dtype=torch.int64,
requires_grad=False,
stride=None,
Expand Down
Loading