Skip to content

Add fused QKV HQQ triton_mm test #306

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

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

jeromeku
Copy link
Contributor

@jeromeku jeromeku commented Jun 3, 2024

Add fused QKV HQQ triton_mm test

Add test / example of how to fuse qkv projections when using the hqq triton_mm fused int4 matmul kernel.

Description

Common pattern in transformer models is to fuse query, key, and value weights such that qkv projection can be fused into single matmul.

In order to use torchao.prototype.hqq.triton_mixed_mm during int4 quantized model training / inference, query, key, and value weights are quantized and packed. This introduces additional complexities when additionally applying this fusion pattern.

Contribution

This PR adds a test that demonstrates how to properly fuse and pack query, key, and v projection weights such that the fused weight can be used with the triton_mixed_mm kernel.

Tests for equivalence of passing single fused qkv into kernel against individual q, k, v kernels for both transposed and non-transposed cases.

@msaroufim @mobicham @KeremTurgutlu

Copy link

pytorch-bot bot commented Jun 3, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/306

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (3 Unrelated Failures)

As of commit 50a9ce7 with merge base 8dbf031 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 3, 2024
@msaroufim msaroufim merged commit 729fa4d into pytorch:main Jun 4, 2024
10 of 13 checks passed
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants