Skip to content

[chore](cuda): explicitly use ele_per_blk var for better readability#1784

Merged
ovowei merged 1 commit intokvcache-ai:mainfrom
SCDESPERTATE:chore/improve_gguf_dequant_readability
Jan 23, 2026
Merged

[chore](cuda): explicitly use ele_per_blk var for better readability#1784
ovowei merged 1 commit intokvcache-ai:mainfrom
SCDESPERTATE:chore/improve_gguf_dequant_readability

Conversation

@SCDESPERTATE
Copy link
Contributor

What does this PR do?

The current implementation of the dequant.* functions in the custom_gguf module uses hardcoded numeric values when creating the output tensor, which reduces readability and could hinder future scalability. This PR replaces these hardcoded values with the name of the variable holding it.

Before submitting

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @SCDESPERTATE, 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 focuses on improving the clarity and future scalability of the dequant.* functions within the custom_gguf module. The core change involves replacing direct numeric values with a descriptive variable, ele_per_blk, when defining the dimensions of output tensors. This refactoring makes the code easier to understand, reduces the risk of errors from inconsistent hardcoded values, and simplifies future modifications.

Highlights

  • Readability Improvement: Replaced hardcoded numeric values with the ele_per_blk variable when creating output tensors in various dequant.* functions, enhancing code readability and maintainability.
  • Consistency: Standardized the dimension specification for output tensors across multiple dequantization functions by using a named variable instead of literal numbers.

🧠 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 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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 improves code readability and maintainability by replacing hardcoded numeric values with the ele_per_blk variable when creating output tensors. The changes are applied consistently across all dequant.* functions in both modified files. This is a good refactoring that makes the code cleaner and easier to understand.

On a related note, I observed that kt-kernel/cuda/custom_gguf/dequant.cu and kt-sft/csrc/ktransformers_ext/cuda/custom_gguf/dequant.cu appear to be identical. This code duplication is a significant maintainability concern. This pull request itself highlights the issue, as the same change had to be applied in two separate places. I strongly recommend consolidating these files into a single source in a future effort to reduce maintenance overhead and prevent potential inconsistencies.

@KMSorSMS KMSorSMS added the run-ci label Jan 8, 2026
@ovowei ovowei self-assigned this Jan 22, 2026
@ovowei ovowei merged commit b0f827d into kvcache-ai:main Jan 23, 2026
9 checks passed
@SCDESPERTATE SCDESPERTATE deleted the chore/improve_gguf_dequant_readability branch January 28, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants