[Refactor] Clean up JIT kernel utilites#16884
Conversation
Summary of ChangesHello @DarkSharpness, 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 significantly refactors the JIT kernel utilities to improve code organization, reusability, and prepare for future hardware support. By introducing a modular set of CUDA primitives and a flexible norm template, it streamlines the development of new kernels and simplifies existing ones, such as per-tensor quantization and various normalization layers. The changes aim to enhance the maintainability and extensibility of the JIT kernel infrastructure. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This pull request is a significant and well-executed refactoring of the JIT kernel utilities. It introduces several new abstractions (tile, type, math, atomic, cta) that greatly improve code organization, readability, and maintainability. The existing per_tensor_quant and qknorm kernels have been cleanly rewritten to leverage these new components, and a new rmsnorm kernel has been added along with corresponding benchmarks and tests. The overall quality of the changes is high. I've identified a couple of minor issues: a potential for silent failure in the new rmsnorm kernel and a naming inconsistency in a new test file. Addressing these will further solidify this excellent contribution.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/tag-and-rerun-ci |
|
Can you post per_tensor_quant and qk_norm kernel's benchmark with main and pr? |
|
|
||
| #include <tvm/ffi/container/tensor.h> | ||
|
|
||
| namespace { |
There was a problem hiding this comment.
It is just a demo of our cta norm template, and we don't plan to land it in deployment since there's no much perf gain against flashinfer baseline.
There was a problem hiding this comment.
Feel free to update the norm template if it is not fastest.
|
perf of After Before: Slightly worse performance for smaller batch size, and slightly better for larger batch size. I guess this could be further optimized. |
|
the only ci break will be fixed by #16912 |
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
Motivation
Currently, the code structure of our JIT kernel is terrible. Also, there're many diffusion PRs that may rely on some common utilities of our JIT kernel #14717, #16404
Modifications
per_tensor_quantcc @BBuf64, 128, 256 * n. cc @jianyingzhu @attack204 (seermsnorm.cuhandqknorm.cuhfor a quick example)Future works:
AlignedVectortype)Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci