Skip to content
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

[torch.compile] Dynamic fp8 + rms_norm fusion #31

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ProExpertProg
Copy link

@ProExpertProg ProExpertProg commented Nov 8, 2024

This PR cleans up the fusion pass to make it easier to add other multi-output patterns. Then it adds dynamic fp8 rmsnorm fusion.

Copy link

github-actions bot commented Nov 8, 2024

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@ProExpertProg ProExpertProg force-pushed the luka/rms-norm-fusion-refactor branch 2 times, most recently from 81ad334 to 7d1adbf Compare November 12, 2024 23:08
@ProExpertProg ProExpertProg changed the title Fusion and functionalization pass refactors [torch.compile] Dynamic fp8 + rms_norm fusion Nov 21, 2024
@ProExpertProg ProExpertProg changed the base branch from luka/rms-norm-fusion to main November 21, 2024 23:48
has_residual>(
out, input, weight, rms, 1.0f / token_scale, hidden_size, residual);
} else {
// FP8 - Do not invert s_token_scale for exact match with FBGemm

Choose a reason for hiding this comment

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

s_token_scale -> token_scale

ss += x * x;
}

using BlockReduce = cub::BlockReduce<float, 1024>;

Choose a reason for hiding this comment

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

the block_dim.x is defined as

 dim3 block(std::min(hidden_size, 1024));

is it safe doing cub::BlockReduce<float,1024> when block_dim.x is < 1024 ?

QUANT_DTYPES = [torch.int8, torch.float8_e4m3fn]
NUM_TOKENS = [1, 7, 83, 2048, 4096] # Arbitrary values for testing
HIDDEN_SIZES = [1, 2, 3, 4, 16, 64, 67, 768, 2048, 5120, 5137, 8192,
8193] # Arbitrary values for testing

Choose a reason for hiding this comment

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

We can probably reduce the hidden_sizes to [1, 3, 4, 16, 64, 2048, 5120, 5137] + the vectorization edge-cases to save test times.

@@ -22,6 +22,7 @@
supports_moe_ops = False
with contextlib.suppress(ImportError):
import vllm._moe_C # noqa: F401

Choose a reason for hiding this comment

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

nit: whitespace changes, here and below

@varun-sundar-rabindranath

Reviewed the kernel files and kernel tests. Left some minor comments. LGTM otherwise.

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.

2 participants