Skip to content

Conversation

@nvjullin
Copy link
Contributor

@nvjullin nvjullin commented Aug 14, 2025

Purpose

Added fp8 gemms from flashinfer.
The added gemms have better or same perf as the original gemms so we use it as the default.
For gemm sizes with small M, the added gemms are marginally faster.
For gemm sizes with large M, the added gemms are much faster.
These are the results for llama3 ISL=OSL=1024 concurrency=128 max_num_batched_tokens=8192 TP1.
As expected, TPOT is roughly the same but TTFT improved by ~13%.

Requires flashinfer autotuning, so depends on #22346 (merged).
Funcionality depends on flashinfer PR flashinfer-ai/flashinfer#1479 (merged).
Perf numbers depends on flashinfer PR flashinfer-ai/flashinfer#1491 (merged).
Requires next flashinfer release including aforementeiond PRs and vllm updating flashinfer version. (updated flashinfer)

old

============ Serving Benchmark Result ============
Successful requests:                     384       
Maximum request concurrency:             128       
Benchmark duration (s):                  133.38    
Total input tokens:                      392638    
Total generated tokens:                  393216    
Request throughput (req/s):              2.88      
Output token throughput (tok/s):         2948.16   
Total Token throughput (tok/s):          5892.00   
---------------Time to First Token----------------
Mean TTFT (ms):                          2955.22   
Median TTFT (ms):                        1330.74   
P99 TTFT (ms):                           10734.06  
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          40.50     
Median TPOT (ms):                        42.68     
P99 TPOT (ms):                           45.28     
---------------Inter-token Latency----------------
Mean ITL (ms):                           40.50     
Median ITL (ms):                         32.10     
P99 ITL (ms):                            653.22    
==================================================

new

============ Serving Benchmark Result ============
Successful requests:                     384       
Maximum request concurrency:             128       
Benchmark duration (s):                  128.33    
Total input tokens:                      392638    
Total generated tokens:                  393216    
Request throughput (req/s):              2.99      
Output token throughput (tok/s):         3064.22   
Total Token throughput (tok/s):          6123.93   
---------------Time to First Token----------------
Mean TTFT (ms):                          2611.05   
Median TTFT (ms):                        1182.85   
P99 TTFT (ms):                           9319.07   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          39.19     
Median TPOT (ms):                        41.07     
P99 TPOT (ms):                           44.23     
---------------Inter-token Latency----------------
Mean ITL (ms):                           39.19     
Median ITL (ms):                         31.65     
P99 ITL (ms):                            560.29    
==================================================

lm_eval shows

|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value|   |Stderr|
|-----|------:|----------------|-----:|-----------|---|----:|---|-----:|
|gsm8k|      3|flexible-extract|     5|exact_match|↑  |0.944|±  |0.0103|
|     |       |strict-match    |     5|exact_match|↑  |0.886|±  |0.0142|

Test Plan

Tests to be added.

Test Result

(Optional) Documentation Update


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for FlashInfer's FP8 GEMM kernels, which is expected to improve performance, particularly for large batch sizes. The changes primarily involve refactoring the GEMM dispatch logic to accommodate a new 'flashinfer' backend and adding an optimization to pre-calculate combined scales. While the implementation is largely sound, I've identified a critical issue in the new FlashInfer wrapper where the output tensor is not reshaped, potentially causing shape mismatches for inputs with more than two dimensions.

@nvjullin nvjullin changed the title Added flashinfer fp8 gemms [Kernel] Added flashinfer fp8 gemms Aug 14, 2025
@nvjullin nvjullin changed the title [Kernel] Added flashinfer fp8 gemms [Kernel] Added flashinfer fp8 per-tensor gemms Aug 14, 2025
@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

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 either: Add ready label to the PR or enable auto-merge.

🚀

Signed-off-by: Julien Lin <jullin@nvidia.com>
@nvjullin nvjullin force-pushed the flashinfer-fp8-gemms branch from 4738c59 to 26ddfd9 Compare August 15, 2025 08:43
Signed-off-by: Julien Lin <jullin@nvidia.com>
Signed-off-by: Julien Lin <jullin@nvidia.com>
@nvjullin nvjullin requested a review from WoosukKwon as a code owner August 18, 2025 07:24
@mergify mergify bot added the ci/build label Aug 18, 2025
nvjullin and others added 3 commits August 18, 2025 07:34
Signed-off-by: Julien Lin <jullin@nvidia.com>
Signed-off-by: Julien Lin <jullin@nvidia.com>
@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 20, 2025
@mgoin
Copy link
Member

mgoin commented Aug 20, 2025

Signed-off-by: Julien Lin <jullin@nvidia.com>
Signed-off-by: Julien Lin <jullin@nvidia.com>
Signed-off-by: Julien Lin <jullin@nvidia.com>
@nvjullin
Copy link
Contributor Author

@mgoin the remaining errors are all something about huggingface gateway timeout

Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

A few minor notes.

This might be a bit too urgent but in general we should really improve the fp8 scaled_mm dispatching. I started a draft pr #19434 but never got around to it.

@nvpohanh
Copy link
Contributor

@nvjullin Please address the comments and rebase this PR. Thanks!

Signed-off-by: Julien Lin <jullin@nvidia.com>
@nvjullin nvjullin force-pushed the flashinfer-fp8-gemms branch from 09089d8 to 9a847f7 Compare August 25, 2025 08:05
Signed-off-by: Julien Lin <jullin@nvidia.com>
@mergify mergify bot removed the needs-rebase label Aug 25, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
@nvjullin
Copy link
Contributor Author

This might be a bit too urgent but in general we should really improve the fp8 scaled_mm dispatching. I started a draft pr #19434 but never got around to it.

@mgoin Is there a specific maintainability problem with the current dispatching code you wish to be addressed?

@ProExpertProg
Copy link
Collaborator

Is there a specific maintainability problem with the current dispatching code you wish to be addressed?

No I think it's out of the scope of this PR. But if you look at dispatching for int8 or Marlin/Machete, that's closer to something we want to do in general when we want to dispatch between multiple possible implementations.

@mergify
Copy link

mergify bot commented Aug 26, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @nvjullin.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 26, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
@mergify mergify bot removed the needs-rebase label Aug 26, 2025
Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

LGTM to get in, thanks. We should follow up with using an Enum instead of raw strings

@simon-mo simon-mo merged commit f66673a into vllm-project:main Aug 26, 2025
68 of 71 checks passed
tc-mb pushed a commit to tc-mb/vllm that referenced this pull request Aug 27, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
Signed-off-by: tc-mb <caitianchi@modelbest.cn>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
Signed-off-by: Xiao Yu <xiao.yu@amd.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Sep 3, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: Julien Lin <jullin@nvidia.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants