Add Batch‑Invariant RMSNorm#12144
Conversation
Summary of ChangesHello @zyzshishui, 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 new batch-invariant RMS normalization capability, designed to enhance the performance and determinism of the SGLang inference engine. By implementing a custom Triton kernel for RMSNorm and integrating it into the existing layer normalization framework, the changes ensure consistent normalization behavior, particularly when operating in a batch-invariant mode. This is a foundational step towards more robust and predictable model execution. Highlights
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 adds a batch-invariant RMS Normalization using a Triton kernel, which is a valuable addition for deterministic inference. The implementation is sound, but I have two main suggestions. First, and most importantly, unit tests are missing for the new functionality. It is critical to add tests to verify correctness and the batch-invariant property, as also indicated by the unchecked item in the PR description's checklist. Second, the performance of the Triton kernel can be improved by using triton.autotune to select an optimal BLOCK_SIZE instead of the current hardcoded value. I've left a specific suggestion for this.
| if is_batch_invariant_mode_enabled(): | ||
| if ( | ||
| residual is not None | ||
| or get_global_server_args().rl_on_policy_target == "fsdp" |
There was a problem hiding this comment.
Will this condition cause difference behavior between fsdp and sglang?
There was a problem hiding this comment.
in true-on-policy-with-fsdp, we should (at least currently) use the forward_native b/c the fused triton kernel may give diff numeric values
There was a problem hiding this comment.
for the fused triton kernel, have we tested whether its batch invariant?

Checklist