Skip to content

Conversation

@alphabetc1
Copy link
Contributor

@alphabetc1 alphabetc1 commented Nov 25, 2025

Motivation

Input prompt was not logged when --log-requests was enabled and --log-requests-level was set to 2 or 3.

log was enabled:
image

while text is None:
image

after fix:
image

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @alphabetc1, 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 logging oversight where the actual text of input prompts was not being captured in logs under certain configurations, particularly when prompts were processed as token IDs. The changes ensure comprehensive logging of input prompts, improving debuggability and traceability for requests, and also refine the internal handling of prompt inputs to correctly determine batch sizes.

Highlights

  • Fix Input Prompt Logging: Resolved a bug where the input prompt text was not logged when --log-requests was enabled and --log-requests-level was 2 or 3, specifically when prompts were provided as input_ids.
  • Prioritize Input IDs for Logging: Modified the _convert_to_internal_request function to explicitly decode and log the prompt text from input_ids under the specified logging conditions, ensuring the full prompt content is captured.
  • Reordered Batch Size Determination Logic: Adjusted the _determine_batch_size logic in io_struct.py to prioritize input_ids over text when inferring batch size, aligning with the primary input method.
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 fixes a bug where the input prompt was not logged when using input_ids. The changes correctly add logic to decode and log the prompt text when necessary. Additionally, the change in io_struct.py to prioritize input_ids over text is a good improvement for consistency. I have one suggestion to make the logging check logic more concise.

Comment on lines 164 to 177
log_requests_level = getattr(
self.tokenizer_manager.server_args, "log_requests_level", 0
)
need_log_text = (
getattr(self.tokenizer_manager.server_args, "log_requests", False)
and log_requests_level >= 2
)
if need_log_text:
prompt_kwargs["text"] = (
processed_messages.prompt
or self.tokenizer_manager.tokenizer.decode(
processed_messages.prompt_ids
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logic for checking whether to log the prompt text can be made more concise. You can combine the getattr calls into a single if statement to improve readability and reduce the number of local variables.

                server_args = self.tokenizer_manager.server_args
                if (
                    getattr(server_args, "log_requests", False)
                    and getattr(server_args, "log_requests_level", 0) >= 2
                ):
                    prompt_kwargs["text"] = (
                        processed_messages.prompt
                        or self.tokenizer_manager.tokenizer.decode(
                            processed_messages.prompt_ids
                        )
                    )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D

@alphabetc1 alphabetc1 force-pushed the bugfix/log-input-prompt branch from d839826 to 16ae233 Compare November 25, 2025 17:47
):
prompt_kwargs["text"] = (
processed_messages.prompt
or self.tokenizer_manager.tokenizer.decode(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not do de-tokenization here.

Copy link
Contributor Author

@alphabetc1 alphabetc1 Nov 26, 2025

Choose a reason for hiding this comment

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

why? or can i de-tokeniozation here

image

@alphabetc1 alphabetc1 force-pushed the bugfix/log-input-prompt branch from 16ae233 to ecb0955 Compare November 26, 2025 14:16
@alphabetc1 alphabetc1 requested a review from hnyls2002 November 27, 2025 04:22
and obj.input_ids is not None
and self.tokenizer is not None
):
decoded = self.tokenizer.decode(obj.input_ids, skip_special_tokens=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a #FIXME comment here, saying this can be moved elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D

@alphabetc1 alphabetc1 force-pushed the bugfix/log-input-prompt branch from ecb0955 to 7cb0d64 Compare November 28, 2025 07:10
@hnyls2002
Copy link
Collaborator

/tag-and-rerun-ci

@hnyls2002 hnyls2002 merged commit 621061f into sgl-project:main Nov 28, 2025
26 of 74 checks passed
harvenstar pushed a commit to harvenstar/sglang that referenced this pull request Dec 4, 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