Repository navigation
wrong number of dimensions - #3880
Conversation
Summary of ChangesHello @f14-bertolotti, 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 addresses a critical dimension unpacking error in a kernel function, ensuring that tensor shapes are correctly interpreted and assigned to their respective variables. This fix is essential for the proper functioning of the 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 correctly addresses an issue in swiglu_DWf_DW_dfg_kernel where unpacking a 3-dimensional tensor's shape into two variables would cause a runtime error. The fix aligns the code with the tensor's expected shape. I've included one suggestion to enhance code clarity by using an explicit assertion for the tensor's dimension, as the unpacked variables are otherwise unused in the function.
|
|
||
| def swiglu_DWf_DW_dfg_kernel(DW, e, g): | ||
| batch_seq_len, hd = e.shape | ||
| batch, seq_len, hd = e.shape |
There was a problem hiding this comment.
While this change correctly fixes the unpacking of e.shape, the variables batch, seq_len, and hd are not used within this function. This can be slightly confusing for future readers. To make the code's intent clearer, which appears to be asserting the tensor's dimensionality, consider using an explicit assertion. This avoids creating unused variables and makes the check's purpose more obvious.
| batch, seq_len, hd = e.shape | |
| assert e.ndim == 3, "Input tensor `e` is expected to be 3-dimensional" |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d1cea5919
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| def swiglu_DWf_DW_dfg_kernel(DW, e, g): | ||
| batch_seq_len, hd = e.shape | ||
| batch, seq_len, hd = e.shape |
There was a problem hiding this comment.
Handle 2D e/g in backward kernel
This change assumes e is 3D (batch, seq_len, hd), but the only caller of swiglu_DWf_DW_dfg_kernel (the LoRA_MLP backward path) explicitly flattens e and g to 2D with view(-1, e.shape[-1]) before invoking the backward kernel. With that callsite, unpacking three dimensions will raise a ValueError at runtime during backward, breaking any training path that uses the SwiGLU LoRA kernel. Keeping the 2D unpack (or accepting both 2D/3D) avoids the crash.
Useful? React with 👍 / 👎.
|
@f14-bertolotti Thanks but as Codex mentioned above, it's flattened already to 2dims :) |
|
I changed it to a comment if that helps - thanks again! |
|
I see, I am a bit puzzled because the forward kernel wants a 3D tensor while the backward kernel wants a 2D tensor instead. |
wrong number of dimensions
I believe that
batch_seq_lenis a typo and it should bebatch, seq_leninstead.