Skip to content

Rename ngram_utils -> ngram_info#11316

Merged
hnyls2002 merged 2 commits intomainfrom
lsyin/rename-spec
Oct 8, 2025
Merged

Rename ngram_utils -> ngram_info#11316
hnyls2002 merged 2 commits intomainfrom
lsyin/rename-spec

Conversation

@hnyls2002
Copy link
Collaborator

For better consistency with spec_utils and eagle_info.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hnyls2002, 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 primarily focuses on enhancing the consistency of module naming within the project's speculative decoding components. By renaming ngram_utils to ngram_info, the codebase adheres more closely to established naming patterns, which improves readability and maintainability. The change involves updating relevant import paths and includes a small, unrelated cleanup of an unused import.

Highlights

  • File Renaming: The file ngram_utils.py has been renamed to ngram_info.py to ensure better consistency with existing spec_utils and eagle_info naming conventions.
  • Import Updates: All references and import statements pointing to the old ngram_utils module have been updated to ngram_info in cuda_graph_runner.py and ngram_worker.py.
  • Code Cleanup: An unused import os statement was removed from spec_utils.py, contributing to minor code cleanup.
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 refactors the codebase by renaming ngram_utils.py to ngram_info.py for better consistency with other modules. The changes correctly update all import paths in the modified files. I also noticed the removal of an unused os import, which is a good cleanup. My main feedback is about a recurring typo (retrive instead of retrieve) in the renamed module and related components. While fixing this is likely out of scope for this PR, I've added comments to highlight this for a follow-up, as it affects code clarity and maintainability.


elif self.model_runner.spec_algorithm.is_ngram():
from sglang.srt.speculative.ngram_utils import NgramVerifyInput
from sglang.srt.speculative.ngram_info import NgramVerifyInput
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this renaming is a good step for consistency, I noticed a recurring typo in the newly named ngram_info module. The NgramVerifyInput class and its usage consistently use retrive instead of retrieve (e.g., retrive_index). This typo seems to be present in other parts of the codebase as well, including the underlying C++ kernels. It would be beneficial to create a follow-up task to correct this typo across the project for improved code clarity and maintainability.

from sglang.srt.server_args import ServerArgs
from sglang.srt.speculative.cpp_ngram.ngram_cache import NgramCache
from sglang.srt.speculative.ngram_utils import NgramVerifyInput
from sglang.srt.speculative.ngram_info import NgramVerifyInput
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The imported NgramVerifyInput from the renamed ngram_info module contains the retrive vs retrieve typo. This typo is also present within the NGRAMWorker class itself in variables like self.retrive_next_token and self.retrive_next_sibling. Correcting these typos in a follow-up PR would improve overall code quality.

@hnyls2002 hnyls2002 merged commit 4b4dc13 into main Oct 8, 2025
24 of 64 checks passed
@hnyls2002 hnyls2002 deleted the lsyin/rename-spec branch October 8, 2025 03:49
ch-tiger1 pushed a commit to ch-tiger1/sglang that referenced this pull request Oct 9, 2025
lpc0220 pushed a commit to lpc0220/sglang that referenced this pull request Oct 29, 2025
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.

2 participants

Comments