Integrate fused flashinfer rope_quantize_fp8_append_paged_kv_cache kernel#19451
Open
leejnau wants to merge 16 commits intosgl-project:mainfrom
Open
Integrate fused flashinfer rope_quantize_fp8_append_paged_kv_cache kernel#19451leejnau wants to merge 16 commits intosgl-project:mainfrom
leejnau wants to merge 16 commits intosgl-project:mainfrom
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
09b7b96 to
c6387ca
Compare
c6387ca to
f17fd50
Compare
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Open
6 tasks
Collaborator
|
This can be reviewed together with #15729 . They are very similar, except that one is for trtllm_mha and one is for trtllm_mla |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently there are two kernels used to perform RoPE + Quantization (first kernel) + KV Cache writing (second kernel). Flashinfer now exposes a single fused kernel that performs RoPE + Quantization + KV Cache: flashinfer-ai/flashinfer#2037
We should use the single fused kernel for improved performance.
Modifications
Call the single fused flashinfer kernel instead of the two separate kernels where possible:
The CUDA graph buffers must be pre-allocated for various metadata requirements.
Accuracy Tests
The container used for testing was
lmsysorg/sglang:v0.5.8. The model tested was DeepSeek R1 FP8 (https://huggingface.co/deepseek-ai/DeepSeek-R1-0528).GPQA Accuracy
server:
client:
Fused kernel GPQA:
0.779625Benchmarking and Profiling
NSys Profile Analysis
The same container was mentioned in the Accuracy Tests section was used.
server:
client:
A variety of concurrency values
<N>were used:1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048. These were tested across both the FP4 (https://huggingface.co/nvidia/DeepSeek-R1-0528-NVFP4) and FP8 (https://huggingface.co/deepseek-ai/DeepSeek-R1-0528) DeepSeek R1 models.On average approximately 1 microsecond per layer was saved using the fused kernel, as observed from examining nsys profiles. As an example, for the FP4 model at concurrency 16, the fused kernel had a duration of 3.691$\mu\text{s}$ :
Whereas the two kernels had a duration of 4.733$\mu\text{s}$ :
Note that these durations include any gaps before or after the kernel(s).
Stress Tests Isolating Decode
A "low noise decode focused" benchmark was run with concurrencies 1 and 4. This should serve to better isolate the performance improvement in the decode step.
server:
fp4:
fp8:
client:
Key Results (Baseline vs Fused)
Takeaways
fp4andfp8models.Conclusion
The fused kernel provides a real, consistent micro-optimization (~+0.5% class) in low-noise serving benchmarks, with no clear regression signal in those checks.
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci