NVIDIA / NVIDIA/TensorRT-LLM

[Feature]: AutoDeploy: linear attention pattern matching

Open
#10,849 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

  • #10893 by @karthikvetrivel — closed without merging
  • #11044 by @karthikvetrivel — closed without merging
AutoDeploy feature request
Dominant language
Python
Stars
14.7k
Forks
2.8k
Avg merge
2d 23h
Merged PRs (30d)
489

Description

🚀 The feature, motivation and pitch

Currently, AutoDeploy supports the following attention types:

  • Quadratic (sdpa) attention
  • Causal conv
  • Mamba2 (SSM)
  • DeltaNet

However, only sdpa attention comes with a set of pattern matcher transforms to automatically detect the attention pattern from a given source model, see the following transforms:
https://github.com/NVIDIA/TensorRT-LLM/blob/3a894951e7defa7fd44c4b972953b327c9cd8047/tensorrt_llm/_torch/auto_deploy/config/default.yaml#L33-L45

For other attention types, the model currently needs to be patched with the torch.ops.auto_deploy.torch_* reference op in order for the compiler to correctly recognize the attention op for later transforms such as sharding and caching.

For example, here is an example patch:
https://github.com/NVIDIA/TensorRT-LLM/blob/ae8f74b6206fb74d7924dacf69017e3491ec2812/tensorrt_llm/_torch/auto_deploy/models/patches/bamba.py#L87-L98

The goal of this ticket is to develop pattern matching transforms akin of the quadratic attention pattern matchers for our linear attention support.

Roughly, the implementation plan could look as follows:

  1. Develop an initial pattern matcher with 1-2 patterns and 1-2 example models
  2. Write a unit test to check if pattern matcher works as expected
  3. Put together a list of relevant hybrid models
  4. Collect all linear attention patterns present in these models
  5. Extent the pattern matcher to handle more patterns
  6. Extend and validate with extended unit test
  7. Test e2e with a couple of integration tests and by removing patches that are now covered by the pattern matcher
Alternatives

No response

Additional context

No response

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.