Skip to content

refactor: unify autotuner for bmm_fp8#1479

Merged
yzh119 merged 3 commits intoflashinfer-ai:mainfrom
ttyio:dev/vincenth/unify-mm-fp8-autotuner
Aug 15, 2025
Merged

refactor: unify autotuner for bmm_fp8#1479
yzh119 merged 3 commits intoflashinfer-ai:mainfrom
ttyio:dev/vincenth/unify-mm-fp8-autotuner

Conversation

@ttyio
Copy link
Collaborator

@ttyio ttyio commented Aug 13, 2025

add "auto" backend and autotune tactics among cutlass, cudnn and cublas.

📌 Description

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

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.

Summary of Changes

Hello @ttyio, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a unified autotuning mechanism for bmm_fp8 (batch matrix multiplication with FP8 precision) operations. It adds an "auto" backend option that intelligently selects the most performant implementation among cuBLAS, cuDNN, and CUTLASS, thereby optimizing performance for various hardware and input configurations.

Highlights

  • New "auto" backend for bmm_fp8: The bmm_fp8 function now supports an "auto" backend option, which automatically selects the most performant GEMM (General Matrix Multiply) kernel among available implementations (cuBLAS, cuDNN, CUTLASS) for FP8 batch matrix multiplication.
  • Refactored FP8 GEMM implementations: The cuBLAS and CUTLASS FP8 GEMM implementations have been refactored into TunableRunner classes, making them compatible with the autotuning framework for dynamic performance optimization.
  • Added cuDNN FP8 GEMM TunableRunner: A new TunableRunner has been introduced for cuDNN FP8 GEMM operations, expanding the range of backends available for autotuning.
  • Unified FP8 GEMM dispatch logic: The dispatch logic for bmm_fp8 has been consolidated into a single autotuning entry point (fp8_gemm_sm100), streamlining the process of selecting the optimal backend based on runtime characteristics.
  • Updated test suite for "auto" backend: The test suite for bmm_fp8 has been updated to include test cases for the new "auto" backend, ensuring its correctness and performance across various configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 an "auto" backend for bmm_fp8 to enable autotuning across cutlass, cudnn, and cublas backends, which is a great enhancement. The code is well-structured and the new autotuning logic is centralized. My feedback focuses on improving code clarity and maintainability by adding missing type hints and simplifying some expressions. I've also suggested a change to improve robustness by handling invalid inputs defensively. Finally, there's a critical fix for the tests to ensure the new autotuning capabilities are properly verified.

@ttyio ttyio force-pushed the dev/vincenth/unify-mm-fp8-autotuner branch from 33049ae to 0702506 Compare August 13, 2025 20:47
@ttyio ttyio changed the title feature: unfiy autotuner for bmm_fp8 refactor: unfiy autotuner for bmm_fp8 Aug 13, 2025
@nvpohanh
Copy link
Contributor

@nvjullin please comment if this works. thanks!

@yongwww yongwww changed the title refactor: unfiy autotuner for bmm_fp8 refactor: unify autotuner for bmm_fp8 Aug 14, 2025
Copy link
Member

@yongwww yongwww left a comment

Choose a reason for hiding this comment

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

overall looks good to me

ttyio added 2 commits August 14, 2025 17:32
add "auto" backend and autotune tactics among cutlass, cudnn and cublas.

Signed-off-by: Vincent Huang <vincenth@nvidia.com>
@ttyio ttyio force-pushed the dev/vincenth/unify-mm-fp8-autotuner branch from f352aa1 to 3db1044 Compare August 14, 2025 17:32
@ttyio
Copy link
Collaborator Author

ttyio commented Aug 14, 2025

@yongwww can I get this merged? thank you!

Copy link
Collaborator

@yzh119 yzh119 left a comment

Choose a reason for hiding this comment

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

LGTM

@yzh119 yzh119 merged commit 1c8f3ab into flashinfer-ai:main Aug 15, 2025
2 checks passed
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.

5 participants