Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Cached attention op for chunked delta rule using the fla kernel library."""
"""Cached attention op for delta rule using the fla kernel library.
Delta Rule is based on this paper: https://arxiv.org/abs/2406.06484
Kernels are based on this repo: https://github.com/fla-org/flash-linear-attention
"""

from typing import List, Tuple

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Custom ops corresponding to fla's chunked delta rule."""
"""Custom ops corresponding to fla's chunked delta rule.
Delta Rule is based on this paper: https://arxiv.org/abs/2406.06484
Kernels are based on this repo: https://github.com/fla-org/flash-linear-attention
"""

from typing import Optional

Expand Down
4 changes: 0 additions & 4 deletions tensorrt_llm/_torch/auto_deploy/custom_ops/l2norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

from tensorrt_llm._torch.modules.fla.l2norm import l2norm_fwd

# TODO: add a pattern matcher for this such that
# 1. pattern match to torch_l2norm
# 2. fuse transform to map to desired backend like fla


@torch.library.custom_op("auto_deploy::torch_l2norm", mutates_args=())
def _torch_l2norm(x: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:
Expand Down
6 changes: 4 additions & 2 deletions tensorrt_llm/_torch/auto_deploy/custom_ops/rms_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ def torch_rmsnorm(input: torch.Tensor, weight: torch.Tensor, eps: float) -> torc
weight: Scaling weights for the normalized output.
eps: Small constant for numerical stability.
"""
input_dtype = input.dtype
# pre-allocate output to ensure same dtype+stride as input
out = torch.empty_like(input)
input = input.to(torch.float32)
variance = input.pow(2).mean(-1, keepdim=True)
input = input * torch.rsqrt(variance + eps)
return (weight * input.to(input_dtype)).contiguous()
out.copy_((weight * input.to(out.dtype)))
return out


@torch_rmsnorm.register_fake
Expand Down
Loading